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 CIVx |
---|
4 | % function varargout = civ(varargin) |
---|
5 | % provides an interface for the software CIVx |
---|
6 | % |
---|
7 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
8 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
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 | |
---|
24 | % Last Modified by GUIDE v2.5 10-Jan-2010 22:04:45 |
---|
25 | % Begin initialization code - DO NOT EDIT |
---|
26 | gui_Singleton = 1; |
---|
27 | gui_State = struct('gui_Name', mfilename, ... |
---|
28 | 'gui_Singleton', gui_Singleton, ... |
---|
29 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
30 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
31 | 'gui_LayoutFcn', [] , ... |
---|
32 | 'gui_Callback', []); |
---|
33 | if nargin && ischar(varargin{1}) |
---|
34 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
35 | end |
---|
36 | |
---|
37 | if nargout |
---|
38 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
39 | else |
---|
40 | gui_mainfcn(gui_State, varargin{:}); |
---|
41 | end |
---|
42 | % End initialization code - DO NOT EDIT |
---|
43 | |
---|
44 | %------------------------------------------------------------------------ |
---|
45 | % --- Executes just before civ is made visible. |
---|
46 | function civ_OpeningFcn(hObject, eventdata, handles, varargin) |
---|
47 | %------------------------------------------------------------------------ |
---|
48 | % This function has no output args, see OutputFcn. |
---|
49 | % hObject handle to figure |
---|
50 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
51 | % handles structure with handles and user data (see GUIDATA) |
---|
52 | % varargin command line arguments to civ (see VARARGIN) |
---|
53 | global test_batch patch_new_exe%=1 if patch processing available |
---|
54 | %filebase: root name |
---|
55 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
56 | %list of field numbers to process |
---|
57 | %subdir: subdirectory of the opened netcdf file |
---|
58 | %ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2), |
---|
59 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
---|
60 | % Choose default command line output for civ |
---|
61 | handles.output = hObject; |
---|
62 | % Update handles structure |
---|
63 | guidata(hObject, handles); |
---|
64 | |
---|
65 | %default initial parameters |
---|
66 | filebase=''; % root file name ('filebase'.civ) |
---|
67 | %nom_type=[]; % nomenclature type |
---|
68 | ext=[]; |
---|
69 | testall=0; |
---|
70 | browse=[]; |
---|
71 | |
---|
72 | %load the initial parameters if the interface is started from uvmat |
---|
73 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
74 | varcell=varargin{1}; |
---|
75 | filebase=varcell{1}; |
---|
76 | nom_type_read=varcell{2}; |
---|
77 | num1=varcell{3}; |
---|
78 | num2=varcell{4}; |
---|
79 | num_a=varcell{5}; |
---|
80 | num_b=varcell{6}; |
---|
81 | subdir=varcell{7}; |
---|
82 | ind_opening=varcell{8}; |
---|
83 | ext=varcell{11}; |
---|
84 | else |
---|
85 | num1=1; % set of field i numbers |
---|
86 | num2=2; % set of field i numbers |
---|
87 | num_a=1; % set of field j numbers (fields a) |
---|
88 | num_b=1; % second set of field j numbers (fields b) |
---|
89 | subdir='A'; % subdir for the netcdf result files |
---|
90 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
91 | end |
---|
92 | |
---|
93 | if exist('ext','var') && length(ext)>1 && (~isempty(imformats(ext(2:end)))||... |
---|
94 | isequal(lower(ext),'.avi'));%if an image file has been opened by uvmat |
---|
95 | set(handles.ext_ima,'String',ext) |
---|
96 | if exist('nom_type_read','var') |
---|
97 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
98 | end |
---|
99 | elseif isequal(ext,'.nc') |
---|
100 | if exist('nom_type_read','var') |
---|
101 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
102 | end |
---|
103 | end |
---|
104 | set(handles.displ_filebase,'String',filebase); |
---|
105 | set(handles.ImaDoc,'UserData',testall); |
---|
106 | set(handles.ImaDoc,'String',ext) |
---|
107 | |
---|
108 | %read names of the .exe file to adjust the interface according to |
---|
109 | %available prog |
---|
110 | %read names of the .exe file |
---|
111 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
112 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
113 | errormsg=[];%default error message |
---|
114 | if isunix |
---|
115 | syst='LINUX'; |
---|
116 | else |
---|
117 | syst='WIN'; |
---|
118 | end |
---|
119 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
120 | if exist(xmlfile,'file') |
---|
121 | try |
---|
122 | t=xmltree(xmlfile); |
---|
123 | sparam=convert(t); |
---|
124 | catch |
---|
125 | errormsg={[' Problem for reading ' xmlfile]; lasterr}; |
---|
126 | end |
---|
127 | else |
---|
128 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
129 | end |
---|
130 | display(syst) |
---|
131 | if ~isempty(errormsg) |
---|
132 | msgbox_uvmat('ERROR',errormsg); |
---|
133 | end |
---|
134 | patch_new_exe=''; |
---|
135 | % todo_patch=''; |
---|
136 | sge=0; |
---|
137 | |
---|
138 | if isfield(sparam,'PatchNew_exe') |
---|
139 | patch_new_exe=sparam.PatchNew_exe; |
---|
140 | end |
---|
141 | |
---|
142 | if isfield(sparam,'SGE') |
---|
143 | sge=str2double(sparam.SGE); |
---|
144 | end |
---|
145 | |
---|
146 | test_batch=sge;%default |
---|
147 | if isfield(sparam,'Todo_path') |
---|
148 | todo_path=sparam.Todo_path; |
---|
149 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
150 | if exist(name_todo,'file') |
---|
151 | test_batch=1; |
---|
152 | end |
---|
153 | end |
---|
154 | if test_batch==0 |
---|
155 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
156 | end |
---|
157 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
158 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
159 | |
---|
160 | %initiate advised operations |
---|
161 | if isequal(ind_opening,[]) |
---|
162 | ind_opening=1; % default |
---|
163 | end |
---|
164 | % set default operation options |
---|
165 | enable_civ1(handles,'off') |
---|
166 | enable_civ2(handles,'off') |
---|
167 | enable_pair1(handles,'on') |
---|
168 | enable_fix1(handles,'off') |
---|
169 | desable_patch1(handles) |
---|
170 | desable_fix2(handles) |
---|
171 | desable_patch2(handles) |
---|
172 | set(handles.CIV1,'Value',0) |
---|
173 | set(handles.FIX1,'Value',0) |
---|
174 | set(handles.PATCH1,'Value',0) |
---|
175 | set(handles.CIV2,'Value',0) |
---|
176 | set(handles.FIX2,'Value',0) |
---|
177 | set(handles.PATCH2,'Value',0) |
---|
178 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
179 | if isequal(ind_opening,1) |
---|
180 | set(handles.CIV1,'Value',1) |
---|
181 | enable_civ1(handles,'on') |
---|
182 | elseif isequal(ind_opening,2) |
---|
183 | set(handles.FIX1,'Value',1) |
---|
184 | enable_fix1(handles,'on') |
---|
185 | elseif isequal(ind_opening,3) |
---|
186 | set(handles.PATCH1,'Value',1) |
---|
187 | enable_patch1(handles) |
---|
188 | elseif isequal(ind_opening,4) |
---|
189 | set(handles.CIV2,'Value',1) |
---|
190 | enable_civ2(handles,1) |
---|
191 | elseif isequal(ind_opening,5) |
---|
192 | set(handles.FIX2,'Value',1) |
---|
193 | enable_fix2(handles) |
---|
194 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
195 | set(handles.list_pair_civ2,'Enable','On') |
---|
196 | set(handles.list_pair_civ2,'Enable','On') |
---|
197 | enable_pair1(handles,'off') |
---|
198 | elseif isequal(ind_opening,6) |
---|
199 | set(handles.PATCH2,'Value',1) |
---|
200 | enable_patch2(handles) |
---|
201 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
202 | set(handles.list_pair_civ2,'Enable','On') |
---|
203 | enable_pair1(handles,'off') |
---|
204 | end |
---|
205 | |
---|
206 | % set the range of fields (1:1 by default) and selected pair |
---|
207 | if isempty(num2)||isequal(num2,num1) |
---|
208 | num_ref_i=num1; |
---|
209 | else |
---|
210 | num_ref_i=floor((num1+num2)/2); |
---|
211 | browse.incr_pair(1)=num2-num1; |
---|
212 | browse.incr_pair(2)=0; |
---|
213 | end |
---|
214 | if isempty(num_b)||isequal(num_a,num_b) |
---|
215 | if isempty(num_a) |
---|
216 | num_ref_j=1; |
---|
217 | else |
---|
218 | num_ref_j=num_a; |
---|
219 | end |
---|
220 | else |
---|
221 | num_ref_j=floor((num_a+num_b)/2); |
---|
222 | browse.incr_pair(2)=num_b-num_a; |
---|
223 | end |
---|
224 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
225 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
226 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
227 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
228 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
229 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
230 | set(handles.browse_root,'UserData',browse); |
---|
231 | if ~isempty(varargin)% the interface is opened from uvmat |
---|
232 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
233 | end |
---|
234 | |
---|
235 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
236 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
237 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
238 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
239 | |
---|
240 | %------------------------------------------------------------------------ |
---|
241 | % --- Outputs from this function are returned to the command line. |
---|
242 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
243 | %------------------------------------------------------------------------ |
---|
244 | % varargout cell array for returning output args (see VARARGOUT); |
---|
245 | % hObject handle to figure |
---|
246 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
247 | % handles structure with handles and user data (see GUIDATA) |
---|
248 | % Get default command line output from handles structure |
---|
249 | varargout{1} = handles.output; |
---|
250 | |
---|
251 | %------------------------------------------------------------------------ |
---|
252 | % --- Executes on button press in browse_root. |
---|
253 | function browse_root_Callback(hObject, eventdata, handles) |
---|
254 | %------------------------------------------------------------------------ |
---|
255 | %get the input file properties |
---|
256 | filebase=get(handles.displ_filebase,'String'); |
---|
257 | oldfile=''; %default |
---|
258 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
259 | dir_perso=prefdir; |
---|
260 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
261 | display(profil_perso) |
---|
262 | if exist(profil_perso,'file') |
---|
263 | h=load (profil_perso); |
---|
264 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
265 | oldfile=h.filebase; |
---|
266 | end |
---|
267 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
268 | oldfile=h.RootPath; |
---|
269 | end |
---|
270 | end |
---|
271 | else |
---|
272 | oldfile=filebase; |
---|
273 | end |
---|
274 | testall=get(handles.ImaDoc,'UserData'); |
---|
275 | ind_opening=1;%default |
---|
276 | browse.incr_pair=[0 0]; %default |
---|
277 | if testall |
---|
278 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
279 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
280 | else % menu selecting only .civ or .avi files |
---|
281 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
282 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
283 | '*.*', 'All Files (*.*)'}; |
---|
284 | end |
---|
285 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
286 | fileinput=[PathName FileName];%complete file name |
---|
287 | sizf=size(fileinput); |
---|
288 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
289 | [path,name,ext]=fileparts(fileinput); |
---|
290 | testeditxml=0; |
---|
291 | if isequal(ext,'.xml') |
---|
292 | testeditxml=1; |
---|
293 | t_browse=xmltree(fileinput); |
---|
294 | head_element=get(t_browse,1); |
---|
295 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
296 | testeditxml=0; |
---|
297 | end |
---|
298 | end |
---|
299 | if testeditxml==1 || isequal(ext,'.xls') |
---|
300 | heditxml=editxml({fileinput}); |
---|
301 | set(heditxml,'Tag','browser') |
---|
302 | waitfor(heditxml,'Tag','idle') |
---|
303 | if ~ishandle(heditxml) |
---|
304 | return |
---|
305 | end |
---|
306 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
307 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
308 | fileinput=get(attr,'UserData'); |
---|
309 | if ~exist(fileinput,'file') |
---|
310 | return |
---|
311 | end |
---|
312 | end |
---|
313 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
314 | filebase=fullfile(RootPath,RootFile); |
---|
315 | % if isequal(nom_type,'*')% all fields in a single file ( movie files) |
---|
316 | % num_i1=1;num_i2=1;num_j1=1;num_j2=1; |
---|
317 | % else |
---|
318 | num_i1=stra2num(str1); |
---|
319 | if isempty(num_i1),num_i1=1;end |
---|
320 | num_i2=stra2num(str2); |
---|
321 | if isempty(num_i2),num_i2=1;end |
---|
322 | num_j1=stra2num(str_a); |
---|
323 | if isempty(num_j1),num_j1=1;end |
---|
324 | num_j2=stra2num(str_b); |
---|
325 | if isempty(num_j2),num_j2=1;end |
---|
326 | if isequal(get(handles.compare,'Value'),1) |
---|
327 | browse=[];%initialisation |
---|
328 | else |
---|
329 | browse=get(handles.browse_root,'UserData'); |
---|
330 | end |
---|
331 | if length(ext)>1 && (~isempty(imformats(ext([2:end])))||... |
---|
332 | isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
333 | set(handles.ext_ima,'String',ext) |
---|
334 | browse.nom_type_ima=nom_type; |
---|
335 | browse.field_count=num_i1; |
---|
336 | % A=imread(fileinput); |
---|
337 | % npxy=size(A); |
---|
338 | % set(handles.ext_ima,'UserData',npxy) |
---|
339 | end |
---|
340 | set(handles.ImaDoc,'String',ext); |
---|
341 | |
---|
342 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
343 | if isequal(ext,'.nc') |
---|
344 | browse.nom_type_nc=nom_type; |
---|
345 | ind_opening=2;% propose 'fix' as the default option |
---|
346 | Data=nc2struct(fileinput,[]); |
---|
347 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
348 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
349 | ind_opening=3; |
---|
350 | end |
---|
351 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
352 | ind_opening=4; |
---|
353 | end |
---|
354 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
355 | ind_opening=5; |
---|
356 | end |
---|
357 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
358 | ind_opening=6; |
---|
359 | end |
---|
360 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
361 | else |
---|
362 | ind_opening=3; %GUI used only for patch |
---|
363 | testciv=0; |
---|
364 | end |
---|
365 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
366 | set(handles.subdir_civ2,'String',subdir); |
---|
367 | browse.testciv=testciv; |
---|
368 | browse.ind_opening=ind_opening; |
---|
369 | end |
---|
370 | set(handles.displ_filebase,'String',filebase); |
---|
371 | set(handles.ImaDoc,'String',ext); |
---|
372 | if ~isempty(num_i1) |
---|
373 | ref_i=num_i1; |
---|
374 | if ~isempty(num_i2) |
---|
375 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
376 | browse.incr_pair(1)=num_i2-num_i1; |
---|
377 | browse.incr_pair(2)=0; |
---|
378 | end |
---|
379 | set(handles.first_i,'String',num2str(ref_i)); |
---|
380 | set(handles.last_i,'String',num2str(ref_i)); |
---|
381 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
382 | end |
---|
383 | if isempty(num_j1) |
---|
384 | set(handles.ref_j,'String','1'); |
---|
385 | else |
---|
386 | ref_j=num_j1; |
---|
387 | if ~isempty(num_j2) |
---|
388 | ref_j=floor((num_j1+num_j2)/2); |
---|
389 | browse.incr_pair(2)=num_j2-num_j1; |
---|
390 | end |
---|
391 | set(handles.first_j,'String',num2str(ref_j)); |
---|
392 | set(handles.last_j,'String',num2str(ref_j)); |
---|
393 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
394 | end |
---|
395 | |
---|
396 | % set default operation options |
---|
397 | enable_civ1(handles,'off') |
---|
398 | enable_civ2(handles,'off') |
---|
399 | enable_pair1(handles,'on') |
---|
400 | enable_fix1(handles,'off') |
---|
401 | desable_patch1(handles) |
---|
402 | desable_fix2(handles) |
---|
403 | desable_patch2(handles) |
---|
404 | set(handles.CIV1,'Value',0) |
---|
405 | set(handles.FIX1,'Value',0) |
---|
406 | set(handles.PATCH1,'Value',0) |
---|
407 | set(handles.CIV2,'Value',0) |
---|
408 | set(handles.FIX2,'Value',0) |
---|
409 | set(handles.PATCH2,'Value',0) |
---|
410 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
411 | if isequal(ind_opening,1) |
---|
412 | set(handles.CIV1,'Value',1) |
---|
413 | enable_civ1(handles,'on') |
---|
414 | elseif isequal(ind_opening,2) |
---|
415 | set(handles.FIX1,'Value',1) |
---|
416 | enable_fix1(handles,'on') |
---|
417 | elseif isequal(ind_opening,3) |
---|
418 | set(handles.PATCH1,'Value',1) |
---|
419 | enable_patch1(handles) |
---|
420 | elseif isequal(ind_opening,4) |
---|
421 | set(handles.CIV2,'Value',1) |
---|
422 | enable_civ2(handles,1) |
---|
423 | elseif isequal(ind_opening,5) |
---|
424 | enable_pair1(handles,'off') |
---|
425 | set(handles.FIX2,'Value',1) |
---|
426 | enable_fix2(handles) |
---|
427 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
428 | set(handles.list_pair_civ2,'Enable','On') |
---|
429 | set(handles.list_pair_civ2,'Enable','On') |
---|
430 | elseif isequal(ind_opening,6) |
---|
431 | enable_pair1(handles,'off') |
---|
432 | set(handles.PATCH2,'Value',1) |
---|
433 | enable_patch2(handles) |
---|
434 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
435 | set(handles.list_pair_civ2,'Enable','On') |
---|
436 | end |
---|
437 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
438 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
439 | set(handles.ImaDoc,'UserData',testall); |
---|
440 | |
---|
441 | displ_filebase_Callback(hObject, eventdata, handles); |
---|
442 | |
---|
443 | %------------------------------------------------------------------------ |
---|
444 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
445 | %------------------------------------------------------------------------ |
---|
446 | displ_filebase_Callback(hObject, eventdata, handles) |
---|
447 | |
---|
448 | %------------------------------------------------------------------------ |
---|
449 | % --- function activated when a new filebase (image series) is introduced |
---|
450 | function displ_filebase_Callback(hObject, eventdata, handles) |
---|
451 | %------------------------------------------------------------------------ |
---|
452 | global test_batch |
---|
453 | set(handles.compare,'Visible','on') |
---|
454 | ext_ima=get(handles.ext_ima,'String'); |
---|
455 | nom_type_ima=[];%default |
---|
456 | field_count=1;%default |
---|
457 | nom_type_nc=[]; |
---|
458 | time=[]; |
---|
459 | TimeUnit=[]; %default |
---|
460 | CoordUnit=[];%default |
---|
461 | pxcmx_search=[];%default |
---|
462 | pxcmy_search=[];%default |
---|
463 | filebase=get(handles.displ_filebase,'String'); |
---|
464 | |
---|
465 | ext=get(handles.ImaDoc,'String'); |
---|
466 | browse=get(handles.browse_root,'UserData');%default |
---|
467 | if ~isempty(browse) |
---|
468 | if isfield(browse,'nom_type_ima') |
---|
469 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
470 | end |
---|
471 | if isfield(browse,'field_count') |
---|
472 | field_count=browse.field_count;% get an image index type already determined by an input file |
---|
473 | end |
---|
474 | end |
---|
475 | |
---|
476 | %default first_i and j and increments |
---|
477 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
478 | if isempty(first_i)|| first_i < 1 |
---|
479 | first_i=1; %default first_i |
---|
480 | end |
---|
481 | last_i=str2num(get(handles.last_i,'String')); |
---|
482 | if isempty(last_i)|| last_i < first_i |
---|
483 | last_i=first_i; %default last_i |
---|
484 | end |
---|
485 | first_j=str2num(get(handles.first_j,'String')); |
---|
486 | if isempty(first_j)|| first_j < 1 |
---|
487 | first_j=1; %default first_j |
---|
488 | end |
---|
489 | last_j=str2num(get(handles.last_j,'String')); |
---|
490 | if isempty(last_j)|| last_j < first_j |
---|
491 | last_j=first_j; %default last_j |
---|
492 | end |
---|
493 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
494 | if isempty(incr_i) || incr_i < 1; |
---|
495 | set(handles.incr_i,'String','1') %default incr_i |
---|
496 | end |
---|
497 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
498 | if isempty(incr_j) || incr_j < 1; |
---|
499 | set(handles.incr_j,'String','1') %default incr_j |
---|
500 | end |
---|
501 | dt=[];%default |
---|
502 | testmode=0;%default |
---|
503 | nbfield=[]; %default |
---|
504 | nburst=[];%default |
---|
505 | pxcmx=1; |
---|
506 | pxcmy=1; |
---|
507 | |
---|
508 | %look for an image documentation file |
---|
509 | if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI') |
---|
510 | if exist([filebase '.xml'],'file') |
---|
511 | ext='.xml'; |
---|
512 | elseif exist([filebase '.civxml'],'file') |
---|
513 | ext='.civxml'; |
---|
514 | elseif exist([filebase '.civ'],'file') |
---|
515 | ext='.civ'; |
---|
516 | elseif exist([filebase '.avi'],'file') |
---|
517 | ext='.avi'; |
---|
518 | elseif exist([filebase '.AVI'],'file') |
---|
519 | ext='.AVI'; |
---|
520 | end |
---|
521 | set(handles.ImaDoc,'String',ext) |
---|
522 | end |
---|
523 | |
---|
524 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
525 | mode=''; %default |
---|
526 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
527 | drawnow |
---|
528 | %read the image documentation file if found |
---|
529 | if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') |
---|
530 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
531 | set(handles.ref_j,'Visible','On') |
---|
532 | set(handles.dt,'Visible','Off') |
---|
533 | set(handles.dt_text,'String','') |
---|
534 | elseif isequal(ext,'.avi') || isequal(ext,'.AVI') |
---|
535 | set(handles.ref_j,'Visible','Off') |
---|
536 | set(handles.dt,'Visible','Off') |
---|
537 | set(handles.dt_text,'String','ref. ind.') |
---|
538 | else |
---|
539 | set(handles.ref_i,'Visible','Off') |
---|
540 | set(handles.ref_j,'Visible','Off') |
---|
541 | set(handles.dt,'Visible','On') |
---|
542 | set(handles.dt_text,'String','dt(ms)=') |
---|
543 | end |
---|
544 | testima_xml=0; |
---|
545 | if isequal(ext,'.civxml')%TO ABANDON |
---|
546 | [nbfield,nburst,time]=read_civxml([filebase '.civxml']); |
---|
547 | mode='pair j1-j2'; |
---|
548 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
549 | nom_type_ima='_i_j'; |
---|
550 | end |
---|
551 | elseif isequal(ext,'.xml') |
---|
552 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
553 | if isfield(XmlData,'Time') |
---|
554 | time=XmlData.Time; |
---|
555 | nbfield=size(time,1); |
---|
556 | nburst=size(time,2); |
---|
557 | end |
---|
558 | ext_ima_read=[]; |
---|
559 | nom_type_read=[]; |
---|
560 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
561 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
562 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
563 | if ~exist(fullname,'file') |
---|
564 | % testima_xml=1; |
---|
565 | % else |
---|
566 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
567 | end |
---|
568 | end |
---|
569 | if isfield(XmlData,'Camera') |
---|
570 | if isfield(XmlData.Camera,'TimeUnit') |
---|
571 | TimeUnit=XmlData.Camera.TimeUnit; |
---|
572 | end |
---|
573 | if isfield(XmlData.Camera,'ImageSize') |
---|
574 | ImageSize=XmlData.Camera.ImageSize; |
---|
575 | if ~isempty(ImageSize)&& ~isempty(ImageSize) |
---|
576 | xindex=findstr(ImageSize,'x'); |
---|
577 | % if length(xindex)>=2 |
---|
578 | % npx=str2num(ImageSize(1:xindex(1)-1)); |
---|
579 | % npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1)); |
---|
580 | % end |
---|
581 | end |
---|
582 | end |
---|
583 | end |
---|
584 | pxcmx_search=1; |
---|
585 | pxcmy_search=1; |
---|
586 | if isfield(XmlData,'GeometryCalib') |
---|
587 | tsai=XmlData.GeometryCalib; |
---|
588 | if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') |
---|
589 | rot2D=tsai.R([1:2],[1,2]); |
---|
590 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
591 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
592 | end |
---|
593 | if isfield(tsai,'CoordUnit') |
---|
594 | CoordUnit=tsai.CoordUnit; |
---|
595 | end |
---|
596 | end |
---|
597 | if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
598 | if isempty(ext_ima) |
---|
599 | ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
600 | else %keep the image extension |
---|
601 | if ~strcmp(ext_ima_read,ext_ima) |
---|
602 | msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
603 | end |
---|
604 | end |
---|
605 | nom_type_ima=nom_type_read; |
---|
606 | end |
---|
607 | elseif isequal(ext,'.civ')% case of .civ image documentation file |
---|
608 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
609 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
610 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
611 | end |
---|
612 | % ext_ima='.png'; |
---|
613 | nom_type_ima='png_old'; |
---|
614 | elseif isequal(lower(ext),'.avi') |
---|
615 | nom_type_ima='*'; |
---|
616 | ext_ima=ext; |
---|
617 | set(handles.mode,'String',{'series(Di)'}) |
---|
618 | dt=0.04;%default |
---|
619 | if exist([filebase ext],'file')==2 |
---|
620 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
621 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
622 | nbfield=info.NumFrames;%number of frames |
---|
623 | end |
---|
624 | time=(dt*[0:nbfield-1])';%list of image times |
---|
625 | set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
626 | end |
---|
627 | if isempty(time) |
---|
628 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
629 | end |
---|
630 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
631 | |
---|
632 | %get the imabe nomenclature type if not defiend by the input file nor by the xml file |
---|
633 | if isempty(nom_type_ima) |
---|
634 | %look for double image series '_i_j' |
---|
635 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
636 | if isempty(dirima) |
---|
637 | % look for images series with sub marker '_' |
---|
638 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
639 | if isempty(dirima) |
---|
640 | % look for other images series |
---|
641 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
642 | if ~isempty(dirima) |
---|
643 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
644 | end |
---|
645 | else |
---|
646 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
647 | end |
---|
648 | else |
---|
649 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
650 | end |
---|
651 | end |
---|
652 | |
---|
653 | % no image documentation file found: look for a series of existing images or .nc files |
---|
654 | if isempty(time) && ~isequal(ext,'.nc') |
---|
655 | subdir=get(handles.subdir_civ1,'String'); |
---|
656 | incr_pair=[0 0];%default |
---|
657 | if isfield(browse,'incr_pair') |
---|
658 | incr_pair=browse.incr_pair; |
---|
659 | end |
---|
660 | nbdetect=0;%test of detected images |
---|
661 | field_i=field_count; |
---|
662 | idetect=1; |
---|
663 | while idetect==1 %look for the maximum file number in the series |
---|
664 | field_i=field_i+1; |
---|
665 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
666 | if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
667 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
668 | nbdetect=1; |
---|
669 | else |
---|
670 | idetect=(exist(imagename,'file')==2); |
---|
671 | end |
---|
672 | %SEE CASE OF NETCDF FILES |
---|
673 | nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
674 | end |
---|
675 | nb_field=field_i;% last detected field number |
---|
676 | field_i=field_count;%look for the minimum file number in the series |
---|
677 | idetect=1; |
---|
678 | while idetect==1 |
---|
679 | field_i=field_i-1; |
---|
680 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
681 | if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
682 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
683 | nbdetect=1; |
---|
684 | else |
---|
685 | idetect=(exist(imagename,'file')==2); |
---|
686 | end |
---|
687 | nbdetect=nbdetect+idetect; |
---|
688 | end |
---|
689 | first_i=max(field_i+1,1); |
---|
690 | %determine the set of times and possible intervals for CIV |
---|
691 | dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
692 | time=(dt*[0:nb_field-1])'; |
---|
693 | set(handles.mode,'String',{'series(Di)'}) |
---|
694 | end |
---|
695 | if isequal(nom_type_ima,'none')% no file numbering used |
---|
696 | first_i=1; |
---|
697 | last_i=1; |
---|
698 | first_j=1; |
---|
699 | last_j=1; |
---|
700 | end |
---|
701 | if exist('time','var') |
---|
702 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
703 | nbfield=size(time,1); |
---|
704 | nbfield2=size(time,2); |
---|
705 | set(handles.displ_filebase,'UserData',time); %store the set of times |
---|
706 | if isempty(TimeUnit) |
---|
707 | set(handles.dt_unit,'String','dt in e-03'); |
---|
708 | set(handles.TimeUnit,'String',''); |
---|
709 | else |
---|
710 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
711 | set(handles.TimeUnit,'String',TimeUnit); |
---|
712 | end |
---|
713 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
714 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
715 | end |
---|
716 | end |
---|
717 | set(handles.CoordUnit,'String',[CoordUnit '/']) |
---|
718 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
719 | % npxy=[npy npx]; |
---|
720 | set(handles.ext_ima,'String',ext_ima) |
---|
721 | set(handles.first_i,'String',num2str(first_i)); |
---|
722 | set(handles.last_i,'String',num2str(last_i));% |
---|
723 | set(handles.first_j,'String',num2str(first_j)); |
---|
724 | set(handles.last_j,'String',num2str(last_j));% |
---|
725 | browse.nom_type_ima=nom_type_ima; |
---|
726 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
727 | |
---|
728 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
729 | if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
730 | set(handles.mode,'String',{'series(Di)'}) |
---|
731 | set(handles.mode,'Value',1) |
---|
732 | elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old') |
---|
733 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
734 | set(handles.mode,'Value',1) |
---|
735 | elseif (nbfield==1)% simple series in j |
---|
736 | set(handles.mode,'String',{'series(Dj)'}) |
---|
737 | set(handles.mode,'Value',1) |
---|
738 | else |
---|
739 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
740 | if nbfield2 <= 5 |
---|
741 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
742 | end |
---|
743 | % else |
---|
744 | % if isequal(mode,'volume') |
---|
745 | % set(handles.mode,'Value',3) |
---|
746 | % elseif nbfield2 <= 5 |
---|
747 | % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
748 | % else |
---|
749 | % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
750 | % end |
---|
751 | end |
---|
752 | |
---|
753 | %update the subdir |
---|
754 | pathdir=fileparts(filebase);%path to the current xml file |
---|
755 | listot=dir(pathdir); |
---|
756 | idir=0; |
---|
757 | listdir={''};%default |
---|
758 | for ilist=1:length(listot) |
---|
759 | if listot(ilist).isdir |
---|
760 | name=listot(ilist).name; |
---|
761 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
762 | idir=idir+1; |
---|
763 | listdir{idir,1}=listot(ilist).name; |
---|
764 | end |
---|
765 | end |
---|
766 | end |
---|
767 | set(handles.list_subdir_civ1,'Value',1) |
---|
768 | set(handles.list_subdir_civ2,'Value',1) |
---|
769 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
770 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
771 | %check wether the current subdir exists: |
---|
772 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
773 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
774 | |
---|
775 | mode_Callback(hObject, eventdata, handles) |
---|
776 | |
---|
777 | %%%%%% initialize waitbars and RUN button |
---|
778 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
779 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
780 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
781 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
782 | set(handles.RUN, 'Enable','On') |
---|
783 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
784 | if isequal(test_batch,1)%if batch installation is available |
---|
785 | set(handles.BATCH, 'Enable','On') |
---|
786 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
787 | end |
---|
788 | |
---|
789 | %%%%% store the root input filename for future opening |
---|
790 | dir_perso=prefdir; |
---|
791 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
792 | RootPath=fileparts(filebase); |
---|
793 | if exist(profil_perso,'file') |
---|
794 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
795 | else |
---|
796 | txt=ver; |
---|
797 | Release=txt(1).Release; |
---|
798 | relnumb=str2num(Release(3:4)); |
---|
799 | if relnumb >= 14 |
---|
800 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
801 | else |
---|
802 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
803 | end |
---|
804 | end |
---|
805 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
806 | set(gcf,'Pointer','arrow') |
---|
807 | |
---|
808 | %------------------------------------------------------------------------ |
---|
809 | % --- Executes on button press in mode. |
---|
810 | function mode_Callback(hObject, eventdata, handles) |
---|
811 | %------------------------------------------------------------------------ |
---|
812 | browse=get(handles.browse_root,'UserData'); |
---|
813 | compare_list=get(handles.compare,'String'); |
---|
814 | val=get(handles.compare,'Value'); |
---|
815 | compare=compare_list{val}; |
---|
816 | if strcmp(compare,'displacement') |
---|
817 | mode='displacement'; |
---|
818 | else |
---|
819 | mode_list=get(handles.mode,'String'); |
---|
820 | mode_value=get(handles.mode,'Value'); |
---|
821 | mode=mode_list{mode_value}; |
---|
822 | end |
---|
823 | displ_num=[];%default |
---|
824 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
825 | % last_i=str2num(get(handles.last_i,'String')); |
---|
826 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
827 | siztime=size(time); |
---|
828 | nbfield=siztime(1); |
---|
829 | nbfield2=siztime(2); |
---|
830 | indchosen=1; %%first pair selected by default |
---|
831 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
832 | dt=1; |
---|
833 | displ=''; |
---|
834 | index=0; |
---|
835 | numlist_a=[]; |
---|
836 | numlist_B=[]; |
---|
837 | %get all the time intervals in bursts |
---|
838 | displ_dt=1;%default |
---|
839 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
840 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
841 | for numod_b=(numod_a+1):nbfield2 |
---|
842 | index=index+1; |
---|
843 | numlist_a(index)=numod_a; |
---|
844 | numlist_b(index)=numod_b; |
---|
845 | if ~isempty(time) |
---|
846 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
847 | displ_dt(index)=dt(numod_a,numod_b); |
---|
848 | else |
---|
849 | displ_dt(index)=1; |
---|
850 | end |
---|
851 | end |
---|
852 | end |
---|
853 | [dtsort,indsort]=sort(displ_dt); |
---|
854 | if ~isempty(numlist_a) |
---|
855 | displ_num(1,:)=numlist_a(indsort); |
---|
856 | displ_num(2,:)=numlist_b(indsort); |
---|
857 | end |
---|
858 | displ_num(3,:)=0; |
---|
859 | displ_num(4,:)=0; |
---|
860 | set(handles.jtext,'Visible','Off') |
---|
861 | set(handles.first_j,'Visible','Off') |
---|
862 | set(handles.last_j,'Visible','Off') |
---|
863 | set(handles.incr_j,'Visible','Off') |
---|
864 | set(handles.nb_field2,'Visible','Off') |
---|
865 | set(handles.ref_j,'Visible','Off') |
---|
866 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
867 | for index=1:min(nbfield2-1,200) |
---|
868 | displ_num(1,index)=-floor(index/2); |
---|
869 | displ_num(2,index)=ceil(index/2); |
---|
870 | displ_num(3,index)=0; |
---|
871 | displ_num(4,index)=0; |
---|
872 | end |
---|
873 | set(handles.jtext,'Visible','On') |
---|
874 | set(handles.first_j,'Visible','On') |
---|
875 | set(handles.last_j,'Visible','On') |
---|
876 | set(handles.incr_j,'Visible','On') |
---|
877 | set(handles.nb_field2,'Visible','On') |
---|
878 | set(handles.ref_j,'Visible','On') |
---|
879 | if nbfield > 1 |
---|
880 | set(handles.itext,'Visible','On') |
---|
881 | set(handles.first_i,'Visible','On') |
---|
882 | set(handles.last_i,'Visible','On') |
---|
883 | set(handles.incr_i,'Visible','On') |
---|
884 | set(handles.nb_field,'Visible','On') |
---|
885 | set(handles.ref_i,'Visible','On') |
---|
886 | else |
---|
887 | set(handles.itext,'Visible','Off') |
---|
888 | set(handles.first_i,'Visible','Off') |
---|
889 | set(handles.last_i,'Visible','Off') |
---|
890 | set(handles.incr_i,'Visible','Off') |
---|
891 | set(handles.nb_field,'Visible','Off') |
---|
892 | set(handles.ref_i,'Visible','Off') |
---|
893 | end |
---|
894 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
895 | for index=1:200%min(nbfield-1,200) |
---|
896 | displ_num(1,index)=0; |
---|
897 | displ_num(2,index)=0; |
---|
898 | displ_num(3,index)=-floor(index/2); |
---|
899 | displ_num(4,index)=ceil(index/2); |
---|
900 | end |
---|
901 | set(handles.itext,'Visible','On') |
---|
902 | set(handles.first_i,'Visible','On') |
---|
903 | set(handles.last_i,'Visible','On') |
---|
904 | set(handles.incr_i,'Visible','On') |
---|
905 | set(handles.nb_field,'Visible','On') |
---|
906 | set(handles.ref_i,'Visible','On') |
---|
907 | if nbfield2 > 1 |
---|
908 | set(handles.jtext,'Visible','On') |
---|
909 | set(handles.first_j,'Visible','On') |
---|
910 | set(handles.last_j,'Visible','On') |
---|
911 | set(handles.incr_j,'Visible','On') |
---|
912 | set(handles.nb_field2,'Visible','On') |
---|
913 | set(handles.ref_j,'Visible','On') |
---|
914 | else |
---|
915 | set(handles.jtext,'Visible','Off') |
---|
916 | set(handles.first_j,'Visible','Off') |
---|
917 | set(handles.last_j,'Visible','Off') |
---|
918 | set(handles.incr_j,'Visible','Off') |
---|
919 | set(handles.nb_field2,'Visible','Off') |
---|
920 | set(handles.ref_j,'Visible','Off') |
---|
921 | end |
---|
922 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
923 | displ_num(1,1)=0; |
---|
924 | displ_num(2,1)=0; |
---|
925 | displ_num(3,1)=0; |
---|
926 | displ_num(4,1)=0; |
---|
927 | if nbfield > 1 |
---|
928 | set(handles.itext,'Visible','On') |
---|
929 | set(handles.first_i,'Visible','On') |
---|
930 | set(handles.last_i,'Visible','On') |
---|
931 | set(handles.incr_i,'Visible','On') |
---|
932 | set(handles.nb_field,'Visible','On') |
---|
933 | set(handles.ref_i,'Visible','On') |
---|
934 | else |
---|
935 | set(handles.itext,'Visible','Off') |
---|
936 | set(handles.first_i,'Visible','Off') |
---|
937 | set(handles.last_i,'Visible','Off') |
---|
938 | set(handles.incr_i,'Visible','Off') |
---|
939 | set(handles.nb_field,'Visible','Off') |
---|
940 | set(handles.ref_i,'Visible','Off') |
---|
941 | end |
---|
942 | if nbfield2 > 1 |
---|
943 | set(handles.jtext,'Visible','On') |
---|
944 | set(handles.first_j,'Visible','On') |
---|
945 | set(handles.last_j,'Visible','On') |
---|
946 | set(handles.incr_j,'Visible','On') |
---|
947 | set(handles.nb_field2,'Visible','On') |
---|
948 | set(handles.ref_j,'Visible','On') |
---|
949 | else |
---|
950 | set(handles.jtext,'Visible','Off') |
---|
951 | set(handles.first_j,'Visible','Off') |
---|
952 | set(handles.last_j,'Visible','Off') |
---|
953 | set(handles.incr_j,'Visible','Off') |
---|
954 | set(handles.nb_field2,'Visible','Off') |
---|
955 | set(handles.ref_j,'Visible','Off') |
---|
956 | end |
---|
957 | end |
---|
958 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
959 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
960 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
961 | |
---|
962 | %------------------------------------------------------------------------ |
---|
963 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
964 | % the field series set by first_i, incr, last_i |
---|
965 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
966 | %------------------------------------------------------------------------ |
---|
967 | set(gcf,'Pointer','watch') |
---|
968 | %nomenclature types |
---|
969 | filebase=get(handles.displ_filebase,'String'); |
---|
970 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
971 | browse=get(handles.browse_root,'UserData'); |
---|
972 | compare_list=get(handles.compare,'String'); |
---|
973 | val=get(handles.compare,'Value'); |
---|
974 | compare=compare_list{val}; |
---|
975 | if strcmp(compare,'displacement') |
---|
976 | mode='displacement'; |
---|
977 | else |
---|
978 | mode_list=get(handles.mode,'String'); |
---|
979 | mode_value=get(handles.mode,'Value'); |
---|
980 | mode=mode_list{mode_value}; |
---|
981 | end |
---|
982 | |
---|
983 | % nomenclature type of the .nc files |
---|
984 | nom_type_ima=[];%default |
---|
985 | if isfield(browse,'nom_type_ima') |
---|
986 | nom_type_ima=browse.nom_type_ima; |
---|
987 | end |
---|
988 | |
---|
989 | %determine nom_type_nc: |
---|
990 | nom_type_nc=[];%default |
---|
991 | if isfield(browse,'nom_type_nc') |
---|
992 | nom_type_nc=browse.nom_type_nc; |
---|
993 | end |
---|
994 | if isempty(nom_type_nc) |
---|
995 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
996 | end |
---|
997 | browse.nom_type_nc=nom_type_nc; |
---|
998 | set(handles.browse_root,'UserData',browse) |
---|
999 | |
---|
1000 | %reads .nc subdirectoy and image numbers from the interface |
---|
1001 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
1002 | % first_i=str2num(get(handles.first_i,'String')); |
---|
1003 | % last_i=str2num(get(handles.last_i,'String')); |
---|
1004 | % incr=str2num(get(handles.incr_i,'String')); |
---|
1005 | % num1=first_i:incr:last_i; |
---|
1006 | % if isempty(num1) |
---|
1007 | % set(handles.list_pair_civ1,'String',{''}); |
---|
1008 | % return |
---|
1009 | % end |
---|
1010 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
1011 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
1012 | ref_j=0; |
---|
1013 | else |
---|
1014 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
1015 | end |
---|
1016 | time=get(handles.displ_filebase,'UserData');%get the set of times |
---|
1017 | if isempty(time) |
---|
1018 | time=[0 1]; |
---|
1019 | end |
---|
1020 | dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
1021 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1022 | |
---|
1023 | %eliminate the first pairs inconsistent with the position |
---|
1024 | if isempty(displ_num) |
---|
1025 | nbpair=0; |
---|
1026 | else |
---|
1027 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1028 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1029 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1030 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1031 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1032 | end |
---|
1033 | end |
---|
1034 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1035 | |
---|
1036 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
1037 | % be performed, while the result is needed for next steps. |
---|
1038 | displ_pair={''}; |
---|
1039 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
1040 | testpair=0; |
---|
1041 | if get(handles.CIV1,'Value')==0 % |
---|
1042 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
1043 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
1044 | set(handles.list_pair_civ1,'String',{}); |
---|
1045 | return |
---|
1046 | end |
---|
1047 | for ipair=1:nbpair |
---|
1048 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1049 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1050 | select(ipair)=exist(filename,'file')==2; |
---|
1051 | end |
---|
1052 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
1053 | if isfield(browse,'incr_pair') |
---|
1054 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1055 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
1056 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1057 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
1058 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
1059 | select(1)=exist(filename,'file')==2; |
---|
1060 | testpair=1; |
---|
1061 | else |
---|
1062 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1063 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
1064 | else |
---|
1065 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
1066 | end |
---|
1067 | set(handles.list_pair_civ1,'String',{''}); |
---|
1068 | %COMPLETER CAS STEREO |
---|
1069 | return |
---|
1070 | end |
---|
1071 | end |
---|
1072 | end |
---|
1073 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1074 | if testpair |
---|
1075 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1076 | elseif ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
1077 | for ipair=1:nbpair |
---|
1078 | if select(ipair) |
---|
1079 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1080 | 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 |
---|
1081 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1082 | end |
---|
1083 | else |
---|
1084 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1085 | end |
---|
1086 | end |
---|
1087 | else |
---|
1088 | for ipair=1:nbpair |
---|
1089 | if select(ipair) |
---|
1090 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
1091 | else |
---|
1092 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1093 | end |
---|
1094 | end |
---|
1095 | end |
---|
1096 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
1097 | if testpair |
---|
1098 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1099 | else |
---|
1100 | for ipair=1:nbpair |
---|
1101 | if select(ipair) |
---|
1102 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1103 | 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 |
---|
1104 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1105 | end |
---|
1106 | elseif testpair |
---|
1107 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
1108 | else |
---|
1109 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1110 | end |
---|
1111 | end |
---|
1112 | end |
---|
1113 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
1114 | for ipair=1:nbpair |
---|
1115 | if select(ipair) |
---|
1116 | 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 |
---|
1117 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1118 | ' :dt= ' num2str(dt*1000)]; |
---|
1119 | else |
---|
1120 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1121 | end |
---|
1122 | end |
---|
1123 | elseif isequal(mode,'displacement') |
---|
1124 | displ_pair={'Di=Dj=0'}; |
---|
1125 | end |
---|
1126 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
1127 | ichoice=min(find(select)); |
---|
1128 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
1129 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
1130 | if initial>nbpair |
---|
1131 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1132 | end |
---|
1133 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
1134 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1135 | end |
---|
1136 | |
---|
1137 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1138 | initial=get(handles.list_pair_civ2,'Value'); |
---|
1139 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
1140 | if ichoice <= length(displ_pair') |
---|
1141 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
1142 | else |
---|
1143 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
1144 | end |
---|
1145 | end |
---|
1146 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1147 | set(gcf,'Pointer','arrow') |
---|
1148 | |
---|
1149 | %------------------------------------------------------------------------ |
---|
1150 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
1151 | %middle of the series set by first_i, incr, last_i |
---|
1152 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
1153 | %------------------------------------------------------------------------ |
---|
1154 | set(gcf,'Pointer','watch') |
---|
1155 | %nomenclature types |
---|
1156 | filebase=get(handles.displ_filebase,'String'); |
---|
1157 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
1158 | browse=get(handles.browse_root,'UserData'); |
---|
1159 | compare_list=get(handles.compare,'String'); |
---|
1160 | val=get(handles.compare,'Value'); |
---|
1161 | compare=compare_list{val}; |
---|
1162 | if strcmp(compare,'displacement') |
---|
1163 | mode='displacement'; |
---|
1164 | else |
---|
1165 | mode_list=get(handles.mode,'String'); |
---|
1166 | mode_value=get(handles.mode,'Value'); |
---|
1167 | mode=mode_list{mode_value}; |
---|
1168 | end |
---|
1169 | |
---|
1170 | % nomenclature type of the .nc files |
---|
1171 | nom_type_ima='ima_num';%default |
---|
1172 | if isfield(browse,'nom_type_ima') |
---|
1173 | nom_type_ima=browse.nom_type_ima; |
---|
1174 | end |
---|
1175 | nom_type_nc='_i1-i2';%default |
---|
1176 | if isfield(browse,'nom_type_nc') |
---|
1177 | nom_type_nc=browse.nom_type_nc; |
---|
1178 | end |
---|
1179 | 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') |
---|
1180 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
1181 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
1182 | nom_type_nc='none'; |
---|
1183 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
1184 | nom_type_nc='_i1-i2'; |
---|
1185 | else |
---|
1186 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
1187 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
1188 | else |
---|
1189 | nom_type_nc='_i_j1-j2'; |
---|
1190 | end |
---|
1191 | end |
---|
1192 | browse.nom_type_nc=nom_type_nc; |
---|
1193 | set(handles.browse_root,'UserData',browse) |
---|
1194 | |
---|
1195 | %reads .nc subdirectory and image numbers from the interface |
---|
1196 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
1197 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
1198 | % first_i=str2num(get(handles.first_i,'String')); |
---|
1199 | % last_i=str2num(get(handles.last_i,'String')); |
---|
1200 | % incr=str2num(get(handles.incr_i,'String')); |
---|
1201 | % num1=first_i:incr:last_i; |
---|
1202 | % if isempty(num1) |
---|
1203 | % set(handles.list_pair_civ2,'Value',1); |
---|
1204 | % set(handles.list_pair_civ2,'String',{''}); |
---|
1205 | % return |
---|
1206 | % end |
---|
1207 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
1208 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
1209 | ref_j=0; |
---|
1210 | else |
---|
1211 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
1212 | end |
---|
1213 | % if isequal(get(handles.dt_text,'String'),'dt(ms)=')%simple series(Di) with equal interval |
---|
1214 | % ref_i=ceil((first_i+last_i)/2); |
---|
1215 | % ref_j=1; |
---|
1216 | % end |
---|
1217 | % ref_i=browse.num_ref;%field number initially selected by the browser |
---|
1218 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
1219 | if isempty(time) |
---|
1220 | time=[0 1];%default |
---|
1221 | end |
---|
1222 | dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
1223 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1224 | |
---|
1225 | |
---|
1226 | %eliminate the first pairs inconsistent with the position |
---|
1227 | if isempty(displ_num) |
---|
1228 | nbpair=0; |
---|
1229 | else |
---|
1230 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1231 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
1232 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1233 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1234 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1235 | end |
---|
1236 | end |
---|
1237 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1238 | |
---|
1239 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
1240 | % be performed, while the result is needed for next steps. |
---|
1241 | displ_pair={''}; %default |
---|
1242 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
1243 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
1244 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
1245 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
1246 | set(handles.list_pair_civ2,'Value',1); |
---|
1247 | set(handles.list_pair_civ2,'String',{''}); |
---|
1248 | return |
---|
1249 | end |
---|
1250 | for ipair=1:nbpair |
---|
1251 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1252 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1253 | select(ipair)=exist(filename,'file')==2; |
---|
1254 | end |
---|
1255 | if isequal(select,zeros(size(1:nbpair))) |
---|
1256 | if isfield(browse,'incr_pair') |
---|
1257 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1258 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
1259 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1260 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
1261 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
1262 | select(1)=exist(filename,'file')==2; |
---|
1263 | else |
---|
1264 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1265 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
1266 | else |
---|
1267 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
1268 | end |
---|
1269 | set(handles.list_pair_civ2,'Value',1); |
---|
1270 | set(handles.list_pair_civ2,'String',{''}); |
---|
1271 | return |
---|
1272 | end |
---|
1273 | end |
---|
1274 | end |
---|
1275 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
1276 | % if ~isequal(get(handles.dt_text,'String'),'dt(ms)=') |
---|
1277 | for ipair=1:nbpair |
---|
1278 | if select(ipair) |
---|
1279 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1280 | 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 |
---|
1281 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1282 | end |
---|
1283 | else |
---|
1284 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1285 | end |
---|
1286 | end |
---|
1287 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
1288 | for ipair=1:nbpair |
---|
1289 | if select(ipair) |
---|
1290 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1291 | 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 |
---|
1292 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1293 | end |
---|
1294 | else |
---|
1295 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1296 | end |
---|
1297 | end |
---|
1298 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
1299 | for ipair=1:nbpair |
---|
1300 | if select(ipair) |
---|
1301 | 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 |
---|
1302 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1303 | ' :dt= ' num2str(dt*1000)]; |
---|
1304 | else |
---|
1305 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1306 | end |
---|
1307 | end |
---|
1308 | elseif isequal(mode,'displacement') |
---|
1309 | displ_pair={'Di=Dj=0'}; |
---|
1310 | end |
---|
1311 | val=get(handles.list_pair_civ2,'Value'); |
---|
1312 | ichoice=min(find(select)); |
---|
1313 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
1314 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
1315 | val=ichoice;% first valid pair proposed by default in the menu |
---|
1316 | end |
---|
1317 | if val>length(displ_pair') |
---|
1318 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
1319 | else |
---|
1320 | set(handles.list_pair_civ2,'Value',val); |
---|
1321 | end |
---|
1322 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1323 | set(gcf,'Pointer','arrow') |
---|
1324 | |
---|
1325 | %------------------------------------------------------------------------ |
---|
1326 | % determine the list of index pairs of processing file |
---|
1327 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
1328 | find_pair_indices(handles,mode) |
---|
1329 | %------------------------------------------------------------------------ |
---|
1330 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
1331 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
1332 | incr=str2double(get(handles.incr_i,'String'));% increment |
---|
1333 | num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair) |
---|
1334 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
1335 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
1336 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
1337 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
1338 | else |
---|
1339 | first_j=1; |
---|
1340 | last_j=1; |
---|
1341 | incr_j=1; |
---|
1342 | end |
---|
1343 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
1344 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
1345 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
1346 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
1347 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
1348 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
1349 | return |
---|
1350 | end |
---|
1351 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
1352 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
1353 | if index_civ2>length(list_civ2) |
---|
1354 | list_civ2=list_civ1; |
---|
1355 | index_civ2=index_civ1; |
---|
1356 | end |
---|
1357 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
1358 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
1359 | return,end; |
---|
1360 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
1361 | return,end; |
---|
1362 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
1363 | return,end; |
---|
1364 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
1365 | return,end; |
---|
1366 | if isequal (mode,'series(Di)') |
---|
1367 | %recognize the pair civ1 from the display |
---|
1368 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
1369 | str_raw=str_civ1(indsel); |
---|
1370 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
1371 | d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
1372 | if indsepar==length(str_raw) |
---|
1373 | d2=str2double(str_civ1([indsel(indsepar)+1:end])); |
---|
1374 | else |
---|
1375 | d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
1376 | end |
---|
1377 | num1_civ1=num_i-d1;% set of first image numbers |
---|
1378 | num2_civ1=num_i+d2; |
---|
1379 | num_a_civ1=num_j; |
---|
1380 | num_b_civ1=num_j; |
---|
1381 | |
---|
1382 | %recognize the pair civ2 from the display |
---|
1383 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
1384 | str_raw=str_civ2(indsel); |
---|
1385 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
1386 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
1387 | if indsepar==length(str_raw) |
---|
1388 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
1389 | else |
---|
1390 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
1391 | end |
---|
1392 | if isempty(d1) |
---|
1393 | num1_civ2=num_i; |
---|
1394 | else |
---|
1395 | num1_civ2=num_i-d1;% set of first image numbers |
---|
1396 | end |
---|
1397 | if isempty(d2) |
---|
1398 | num2_civ2=num_i; |
---|
1399 | else |
---|
1400 | num2_civ2=num_i+d2; |
---|
1401 | end |
---|
1402 | num_a_civ2=num_j; |
---|
1403 | num_b_civ2=num_j; |
---|
1404 | |
---|
1405 | % adjust the first and last field number |
---|
1406 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
1407 | if isequal(lastfield,[]) |
---|
1408 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
1409 | else |
---|
1410 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
1411 | end |
---|
1412 | if length(indsel)>=1 |
---|
1413 | firstind=indsel(1); |
---|
1414 | lastind=indsel(end); |
---|
1415 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
1416 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
1417 | num_i=num_i(indsel); |
---|
1418 | num1_civ1=num1_civ1(indsel); |
---|
1419 | num1_civ2=num1_civ2(indsel); |
---|
1420 | num2_civ1=num2_civ1(indsel); |
---|
1421 | num2_civ2=num2_civ2(indsel); |
---|
1422 | end |
---|
1423 | elseif isequal (mode,'series(Dj)') |
---|
1424 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
1425 | num1_civ1=num_i;% set of first image numbers |
---|
1426 | num2_civ1=num_i; |
---|
1427 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
1428 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
1429 | num1_civ2=num_i; |
---|
1430 | num2_civ2=num_i; |
---|
1431 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
1432 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
1433 | % adjust the first and last field number |
---|
1434 | if isequal(lastfield_j,[]) |
---|
1435 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
1436 | else |
---|
1437 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
1438 | end |
---|
1439 | if length(indsel)>=1 |
---|
1440 | firstind=indsel(1); |
---|
1441 | lastind=indsel(end); |
---|
1442 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
1443 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
1444 | num_j=num_j(indsel); |
---|
1445 | num_a_civ1=num_a_civ1(indsel); |
---|
1446 | num_a_civ2=num_a_civ2(indsel); |
---|
1447 | num_b_civ1=num_b_civ1(indsel); |
---|
1448 | num_b_civ2=num_b_civ2(indsel); |
---|
1449 | end |
---|
1450 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
1451 | num1_civ1=num_i; |
---|
1452 | num1_civ2=num_i; |
---|
1453 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1454 | num2_civ1=num_i; |
---|
1455 | num_a_civ1=displ_num(1,index_civ1); |
---|
1456 | num_b_civ1=displ_num(2,index_civ1); |
---|
1457 | num2_civ2=num_i; |
---|
1458 | num_a_civ2=displ_num(1,index_civ2); |
---|
1459 | num_b_civ2=displ_num(2,index_civ2); |
---|
1460 | elseif isequal(mode,'displacement') |
---|
1461 | num1_civ1=num_i; |
---|
1462 | num2_civ1=num_i; |
---|
1463 | num_a_civ1=num_j; |
---|
1464 | num_b_civ1=num_j; |
---|
1465 | num1_civ2=num_i; |
---|
1466 | num2_civ2=num_i; |
---|
1467 | num_a_civ2=num_j; |
---|
1468 | num_b_civ2=num_j; |
---|
1469 | end |
---|
1470 | |
---|
1471 | |
---|
1472 | %------------------------------------------------------------------------ |
---|
1473 | % --- Executes on selection change in list_pair_civ1. |
---|
1474 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
1475 | %------------------------------------------------------------------------ |
---|
1476 | %reproduce by default the chosen pair in the civ2 menu |
---|
1477 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
1478 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
1479 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1480 | num_a=displ_num(1,index_pair); |
---|
1481 | num_b=displ_num(2,index_pair); |
---|
1482 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
1483 | if index_pair<=length(list_pair2) |
---|
1484 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
1485 | end |
---|
1486 | |
---|
1487 | %update first_i and last_i according to the chosen image pairs |
---|
1488 | mode_list=get(handles.mode,'String'); |
---|
1489 | mode_value=get(handles.mode,'Value'); |
---|
1490 | mode=mode_list{mode_value}; |
---|
1491 | if isequal(mode,'series(Di)') |
---|
1492 | first_i=str2num(get(handles.first_i,'String')); |
---|
1493 | last_i=str2num(get(handles.last_i,'String')); |
---|
1494 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
1495 | num1=first_i:incr_i:last_i; |
---|
1496 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
1497 | if ~isequal(lastfield,[]) |
---|
1498 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1499 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
1500 | num1=num1(ind); |
---|
1501 | end |
---|
1502 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1503 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1504 | elseif isequal(mode,'series(Dj)') |
---|
1505 | first_j=str2num(get(handles.first_j,'String')); |
---|
1506 | last_j=str2num(get(handles.last_j,'String')); |
---|
1507 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
1508 | num_j=first_j:incr_j:last_j; |
---|
1509 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
1510 | if ~isequal(lastfield2,[]) |
---|
1511 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1512 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
1513 | num1=num_j(ind); |
---|
1514 | end |
---|
1515 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1516 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1517 | end |
---|
1518 | |
---|
1519 | %------------------------------------------------------------------------ |
---|
1520 | % --- Executes on selection change in list_pair_civ2. |
---|
1521 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
1522 | %------------------------------------------------------------------------ |
---|
1523 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
1524 | |
---|
1525 | %update first_i and last_i according to the chosen image pairs |
---|
1526 | mode_list=get(handles.mode,'String'); |
---|
1527 | mode_value=get(handles.mode,'Value'); |
---|
1528 | mode=mode_list{mode_value}; |
---|
1529 | if isequal(mode,'series(Di)') |
---|
1530 | first_i=str2num(get(handles.first_i,'String')); |
---|
1531 | last_i=str2num(get(handles.last_i,'String')); |
---|
1532 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
1533 | num1=first_i:incr_i:last_i; |
---|
1534 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
1535 | if ~isequal(lastfield,[]) |
---|
1536 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1537 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
1538 | num1=num1(ind); |
---|
1539 | end |
---|
1540 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1541 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1542 | elseif isequal(mode,'series(Dj)') |
---|
1543 | first_j=str2num(get(handles.first_j,'String')); |
---|
1544 | last_j=str2num(get(handles.last_j,'String')); |
---|
1545 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
1546 | num_j=first_j:incr_j:last_j; |
---|
1547 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
1548 | if ~isequal(lastfield2,[]) |
---|
1549 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1550 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
1551 | num1=num_j(ind); |
---|
1552 | end |
---|
1553 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1554 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1555 | end |
---|
1556 | |
---|
1557 | %------------------------------------------------------------------------ |
---|
1558 | % --- Executes on button press in RUN. |
---|
1559 | function RUN_Callback(hObject, eventdata, handles) |
---|
1560 | %------------------------------------------------------------------------ |
---|
1561 | global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
1562 | |
---|
1563 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
1564 | %check the list of operations: |
---|
1565 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
1566 | run_flag=1; |
---|
1567 | box_test(1)=get(handles.CIV1,'Value'); |
---|
1568 | box_test(2)=get(handles.FIX1,'Value'); |
---|
1569 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
1570 | box_test(4)=get(handles.CIV2,'Value'); |
---|
1571 | box_test(5)=get(handles.FIX2,'Value'); |
---|
1572 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
1573 | index=find(box_test==1); |
---|
1574 | if isempty(index) |
---|
1575 | msgbox_uvmat('ERROR','no selected operation') |
---|
1576 | return |
---|
1577 | end |
---|
1578 | index_first=min(index); |
---|
1579 | index_last=max(index); |
---|
1580 | box_used=box_test([index_first : index_last]); |
---|
1581 | [box_missing,ind_missing]=min(box_used); |
---|
1582 | if isequal(box_missing,0) |
---|
1583 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
1584 | return |
---|
1585 | end |
---|
1586 | |
---|
1587 | %root name |
---|
1588 | filebase=get(handles.displ_filebase,'String'); |
---|
1589 | if isempty(filebase)||isequal(filebase,'') |
---|
1590 | msgbox_uvmat('ERROR','no input files') |
---|
1591 | return |
---|
1592 | end |
---|
1593 | %check mask if selecetd |
---|
1594 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
1595 | maskname=get(handles.mask_civ1,'String'); |
---|
1596 | if ~exist(maskname,'file') |
---|
1597 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
1598 | end |
---|
1599 | end |
---|
1600 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
1601 | maskname=get(handles.mask_fix1,'String'); |
---|
1602 | if ~exist(maskname,'file') |
---|
1603 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
1604 | end |
---|
1605 | end |
---|
1606 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
1607 | maskname=get(handles.mask_civ2,'String'); |
---|
1608 | if ~exist(maskname,'file') |
---|
1609 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
1610 | end |
---|
1611 | end |
---|
1612 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
1613 | maskname=get(handles.mask_fix2,'String'); |
---|
1614 | if ~exist(maskname,'file') |
---|
1615 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
1616 | end |
---|
1617 | end |
---|
1618 | |
---|
1619 | %read names of the .exe file |
---|
1620 | if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1 |
---|
1621 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
1622 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
1623 | %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
1624 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
1625 | if exist(xmlfile,'file') |
---|
1626 | t=xmltree(xmlfile); |
---|
1627 | sparam=convert(t); |
---|
1628 | end |
---|
1629 | if isfield(sparam,'Civ1_exe') |
---|
1630 | civ1_exe=sparam.Civ1_exe; |
---|
1631 | if ~exist(civ1_exe,'file') |
---|
1632 | civ1_exe=fullfile(path_UVMAT,civ1_exe); |
---|
1633 | end |
---|
1634 | end |
---|
1635 | if isfield(sparam,'Civ2_exe') |
---|
1636 | civ2_exe=sparam.Civ2_exe; |
---|
1637 | if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting |
---|
1638 | civ2_exe=fullfile(path_UVMAT,civ2_exe); |
---|
1639 | end |
---|
1640 | end |
---|
1641 | if isfield(sparam,'Patch_exe') |
---|
1642 | patch_exe=sparam.Patch_exe; |
---|
1643 | if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting |
---|
1644 | patch_exe=fullfile(path_UVMAT,patch_exe); |
---|
1645 | end |
---|
1646 | end |
---|
1647 | if isfield(sparam,'Stinterp_exe') |
---|
1648 | stinterp_exe=sparam.Stinterp_exe; |
---|
1649 | end |
---|
1650 | if isfield(sparam,'SGE') |
---|
1651 | sge=str2double(sparam.SGE); |
---|
1652 | end |
---|
1653 | if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
1654 | dircur=pwd; |
---|
1655 | if ~isequal(dircur([2 3]),':\') |
---|
1656 | msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
1657 | return; |
---|
1658 | end |
---|
1659 | end |
---|
1660 | end |
---|
1661 | |
---|
1662 | %initialize the waitbars |
---|
1663 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
1664 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
1665 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
1666 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
1667 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1668 | set(handles.RUN, 'Enable','Off') |
---|
1669 | drawnow |
---|
1670 | |
---|
1671 | % get the list of file names and check the files |
---|
1672 | display('checking the files...') |
---|
1673 | [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]=... |
---|
1674 | set_civ_filenames(handles,compare,box_test); |
---|
1675 | nbfield=numel(num1_civ1); |
---|
1676 | nbslice=size(num_a_civ1); |
---|
1677 | |
---|
1678 | if isempty(filecell) |
---|
1679 | set(handles.RUN, 'Enable','On') |
---|
1680 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1681 | set(handles.BATCH, 'Enable','On') |
---|
1682 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
1683 | return |
---|
1684 | end |
---|
1685 | display('files OK, processing...') |
---|
1686 | nbfield=size(num1_civ1,2); |
---|
1687 | nbslice=size(num1_civ1,1); |
---|
1688 | |
---|
1689 | %RUN CIV1 |
---|
1690 | if box_test(1)==1 |
---|
1691 | RUN_CIV1(handles,filecell.ima1.civ1,filecell.ima2.civ1,filecell.nc.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) |
---|
1692 | if compare==3 |
---|
1693 | RUN_CIV1(handles,filecell.imaA1.civ1,filecell.imaA2.civ1,filecell.ncA.civ1,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,nom_type_nc) |
---|
1694 | end |
---|
1695 | end |
---|
1696 | |
---|
1697 | %RUN FIX1 |
---|
1698 | if box_test(2)==1 |
---|
1699 | filebase=get(handles.displ_filebase,'String'); |
---|
1700 | %names of the civ1 fields |
---|
1701 | field1.vel_type='civ1'; |
---|
1702 | field1.nb='nb_vectors'; |
---|
1703 | % field1.X='vec_X'; |
---|
1704 | % field1.Y='vec_Y'; |
---|
1705 | % field1.U='vec_U'; |
---|
1706 | % field1.V='vec_V'; |
---|
1707 | field1.fixflag='vec_FixFlag'; |
---|
1708 | flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
1709 | flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
1710 | flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
1711 | thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
1712 | thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
1713 | inf_sup=get(handles.inf_sup1,'Value'); |
---|
1714 | menu=get(handles.field_ref1,'String'); |
---|
1715 | index=get(handles.field_ref1,'Value'); |
---|
1716 | if isempty(menu) |
---|
1717 | fieldchoice=''; |
---|
1718 | else |
---|
1719 | fieldchoice=menu{index}; |
---|
1720 | end |
---|
1721 | h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar |
---|
1722 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
1723 | if test_mask |
---|
1724 | maskdispl=get(handles.mask_fix1,'String'); |
---|
1725 | if exist(maskdispl,'file') |
---|
1726 | test_mask=2; |
---|
1727 | maskname=maskdispl; |
---|
1728 | else |
---|
1729 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
1730 | end |
---|
1731 | end |
---|
1732 | for ifile=1:nbfield |
---|
1733 | waitbar(ifile/nbfield); %update the waitbar |
---|
1734 | for j=1:nbslice |
---|
1735 | if test_mask==0 |
---|
1736 | maskname='noFile use default'; |
---|
1737 | maskflag=0; |
---|
1738 | elseif test_mask==1 |
---|
1739 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
1740 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
1741 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
1742 | maskflag= exist(maskname,'file')==2; |
---|
1743 | if ~maskflag; |
---|
1744 | maskname='noFile use default'; |
---|
1745 | end |
---|
1746 | end |
---|
1747 | if ~isempty(file_ref_fix1) |
---|
1748 | file_ref=file_ref_fix1{ifile,j}; |
---|
1749 | else |
---|
1750 | file_ref=''; |
---|
1751 | end |
---|
1752 | error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
1753 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
1754 | |
---|
1755 | if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
1756 | if test_mask==0 |
---|
1757 | maskname='noFile use default'; |
---|
1758 | maskflag=0; |
---|
1759 | else |
---|
1760 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
1761 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
1762 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
1763 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1764 | maskflag= exist(maskname,'file')==2; |
---|
1765 | if ~maskflag; |
---|
1766 | maskname='noFile use default'; |
---|
1767 | end |
---|
1768 | end |
---|
1769 | error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
1770 | thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
1771 | if ~isempty(error) |
---|
1772 | msgbox_uvmat('ERROR',error) |
---|
1773 | return |
---|
1774 | end |
---|
1775 | end |
---|
1776 | end |
---|
1777 | end |
---|
1778 | close(h) |
---|
1779 | end |
---|
1780 | |
---|
1781 | % RUN PATCH1 |
---|
1782 | if box_test(3)==1 |
---|
1783 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
1784 | if isempty(rho_patch1) |
---|
1785 | rho_patch1='1000'; |
---|
1786 | set(handles.rho_patch1,'String','1') |
---|
1787 | else |
---|
1788 | rho_patch1=num2str(1000*rho_patch1); |
---|
1789 | end |
---|
1790 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
1791 | if isequal(str2num(nx_patch1),[]) |
---|
1792 | nx_patch1='50' ;%default |
---|
1793 | set(handles.nx_patch1,'String','50'); |
---|
1794 | end |
---|
1795 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
1796 | if isequal(str2num(ny_patch1),[]) |
---|
1797 | ny_patch1='50' ;%default |
---|
1798 | set(handles.ny_patch1,'String','50'); |
---|
1799 | end |
---|
1800 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
1801 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
1802 | test_interp=get(handles.test_interp,'Value'); |
---|
1803 | icount=0; |
---|
1804 | for ifile=1:nbfield |
---|
1805 | for j=1:nbslice |
---|
1806 | icount=icount+1; |
---|
1807 | barlength=0.188*icount/(nbfield*nbslice); |
---|
1808 | set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
1809 | drawnow |
---|
1810 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
1811 | cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
1812 | s=-1; |
---|
1813 | if sge |
---|
1814 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1815 | end |
---|
1816 | if s~=0 |
---|
1817 | display(['!' cmd]) |
---|
1818 | eval(['!' cmd]); |
---|
1819 | end |
---|
1820 | |
---|
1821 | %stereo case: |
---|
1822 | elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
1823 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
1824 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
1825 | nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
1826 | display(['!' cmd]) |
---|
1827 | eval(['!' cmd]); |
---|
1828 | else |
---|
1829 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
1830 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
1831 | end |
---|
1832 | end |
---|
1833 | if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
1834 | cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
1835 | s=-1; |
---|
1836 | if sge |
---|
1837 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1838 | end |
---|
1839 | if s~=0 |
---|
1840 | display(['!' cmd]) |
---|
1841 | eval(['!' cmd]); |
---|
1842 | end |
---|
1843 | end |
---|
1844 | end |
---|
1845 | end |
---|
1846 | end |
---|
1847 | |
---|
1848 | % CIV2 |
---|
1849 | if box_test(4)==1 |
---|
1850 | RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
1851 | num_a_civ2,num_b_civ2,nom_type_nc) |
---|
1852 | end |
---|
1853 | |
---|
1854 | % FIX2 |
---|
1855 | if box_test(5)==1 |
---|
1856 | %names of the civ2 fields |
---|
1857 | field2.vel_type='civ2'; |
---|
1858 | field2.nb='nb_vectors2'; |
---|
1859 | field2.X='vec2_X'; |
---|
1860 | field2.Y='vec2_Y'; |
---|
1861 | field2.U='vec2_U'; |
---|
1862 | field2.V='vec2_V'; |
---|
1863 | field2.fixflag='vec2_FixFlag'; |
---|
1864 | flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
1865 | flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
1866 | flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
1867 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
1868 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
1869 | inf_sup=get(handles.inf_sup2,'Value'); |
---|
1870 | menu=get(handles.field_ref2,'String'); |
---|
1871 | index=get(handles.field_ref2,'Value'); |
---|
1872 | if isempty(menu) |
---|
1873 | fieldchoice=''; |
---|
1874 | else |
---|
1875 | fieldchoice=menu{index}; |
---|
1876 | end |
---|
1877 | h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
1878 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
1879 | if test_mask |
---|
1880 | maskdispl=get(handles.mask_fix2,'String'); |
---|
1881 | if exist(maskdispl,'file') |
---|
1882 | test_mask=2; |
---|
1883 | maskname=maskdispl; |
---|
1884 | else |
---|
1885 | maskbase=[get(handles.displ_filebase,'String') '_' maskdispl]; % mask root name |
---|
1886 | end |
---|
1887 | end |
---|
1888 | for ifile=1:nbfield |
---|
1889 | waitbar(ifile/nbfield); %update the waitbar |
---|
1890 | for j=1:nbslice |
---|
1891 | if test_mask==0 |
---|
1892 | maskname='noFile use default'; |
---|
1893 | maskflag=0; |
---|
1894 | elseif test_mask==1 |
---|
1895 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
1896 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
1897 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1898 | maskflag= exist(maskname,'file')==2; |
---|
1899 | if ~maskflag; |
---|
1900 | maskname='noFile use default'; |
---|
1901 | end |
---|
1902 | end |
---|
1903 | if ~isempty(file_ref_fix2) |
---|
1904 | file_ref=file_ref_fix2{ifile,j}; |
---|
1905 | else |
---|
1906 | file_ref=''; |
---|
1907 | end |
---|
1908 | error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
1909 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
1910 | if ~isempty(error) |
---|
1911 | msgbox_uvmat('ERROR',error) |
---|
1912 | return |
---|
1913 | end |
---|
1914 | if compare==3 |
---|
1915 | if test_mask==0 |
---|
1916 | maskname='noFile use default'; |
---|
1917 | maskflag=0; |
---|
1918 | else |
---|
1919 | maskbase=[get(handles.displ_filebase2,'String') '_' maskdispl]; % mask root name |
---|
1920 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
1921 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
1922 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1923 | maskflag= exist(maskname,'file')==2; |
---|
1924 | if ~maskflag; |
---|
1925 | maskname='noFile use default'; |
---|
1926 | end |
---|
1927 | end |
---|
1928 | error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
1929 | thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
1930 | if ~isempty(error) |
---|
1931 | msgbox_uvmat('ERROR',error) |
---|
1932 | return |
---|
1933 | end |
---|
1934 | end |
---|
1935 | end |
---|
1936 | end |
---|
1937 | close(h) |
---|
1938 | end |
---|
1939 | |
---|
1940 | %PATCH 2 |
---|
1941 | if box_test(6)==1 |
---|
1942 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
1943 | if isempty(rho_patch2) |
---|
1944 | rho_patch2='1000'; |
---|
1945 | set(handles.rho_patch2,'String','1') |
---|
1946 | else |
---|
1947 | rho_patch2=num2str(1000*rho_patch2); |
---|
1948 | end |
---|
1949 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
1950 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
1951 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
1952 | if isequal(str2num(nx_patch2),[]) |
---|
1953 | nx_patch2='50' ;%default |
---|
1954 | set(handles.nx_patch2,'String','50'); |
---|
1955 | end |
---|
1956 | if isequal(str2num(ny_patch2),[]) |
---|
1957 | ny_patch2='50' ;%default |
---|
1958 | set(handles.ny_patch2,'String','50'); |
---|
1959 | end |
---|
1960 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
1961 | icount=0; |
---|
1962 | for ifile=1:nbfield |
---|
1963 | for j=1:nbslice |
---|
1964 | icount=icount+1; |
---|
1965 | barlength=0.188*icount/(nbfield*nbslice); |
---|
1966 | set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
1967 | drawnow |
---|
1968 | if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
1969 | cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
1970 | s=-1; |
---|
1971 | if sge |
---|
1972 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1973 | end |
---|
1974 | if s~=0 |
---|
1975 | display(['!' cmd]) |
---|
1976 | eval(['!' cmd]); |
---|
1977 | end |
---|
1978 | elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
1979 | if exist('stinterp_exe','var')%Prog Gauthier |
---|
1980 | cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
1981 | nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
1982 | display(['!' cmd]) |
---|
1983 | eval(['!' cmd]) |
---|
1984 | else |
---|
1985 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
1986 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
1987 | end |
---|
1988 | end |
---|
1989 | if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
1990 | cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
1991 | s=-1; |
---|
1992 | if sge |
---|
1993 | [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1994 | end |
---|
1995 | if s~=0 |
---|
1996 | display(['!' cmd]) |
---|
1997 | eval(['!' cmd]); |
---|
1998 | end |
---|
1999 | end |
---|
2000 | end |
---|
2001 | end |
---|
2002 | end |
---|
2003 | |
---|
2004 | set(handles.RUN, 'Enable','On') |
---|
2005 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
2006 | |
---|
2007 | %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
2008 | if isfield(filecell,'st') |
---|
2009 | fileresu=filecell.st{1,1}; |
---|
2010 | elseif isfield(filecell,'nc') |
---|
2011 | if isfield(filecell.nc,'civ2') |
---|
2012 | fileresu=filecell.nc.civ2{1,1}; |
---|
2013 | else |
---|
2014 | fileresu=filecell.nc.civ1{1,1}; |
---|
2015 | end |
---|
2016 | end |
---|
2017 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
2018 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
2019 | detect=1; |
---|
2020 | while detect==1 |
---|
2021 | namefigfull=[namedoc '.fig']; |
---|
2022 | hh=dir(namefigfull); |
---|
2023 | if ~isempty(hh) |
---|
2024 | detect=1; |
---|
2025 | namedoc=[namedoc '.0']; |
---|
2026 | else |
---|
2027 | detect=0; |
---|
2028 | end |
---|
2029 | end |
---|
2030 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
2031 | |
---|
2032 | %------------------------------------------------------------------------ |
---|
2033 | % --- Executes on button press in BATCH: remote processing |
---|
2034 | function BATCH_Callback(hObject, eventdata, handles) |
---|
2035 | %------------------------------------------------------------------------ |
---|
2036 | global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe |
---|
2037 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
2038 | |
---|
2039 | %check the list of operations: |
---|
2040 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
2041 | run_flag=1; |
---|
2042 | box_test(1)=get(handles.CIV1,'Value'); |
---|
2043 | box_test(2)=get(handles.FIX1,'Value'); |
---|
2044 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
2045 | box_test(4)=get(handles.CIV2,'Value'); |
---|
2046 | box_test(5)=get(handles.FIX2,'Value'); |
---|
2047 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
2048 | index=find(box_test==1); |
---|
2049 | if isempty(index) |
---|
2050 | msgbox_uvmat('ERROR','no selected operation') |
---|
2051 | return |
---|
2052 | end |
---|
2053 | index_first=min(index); |
---|
2054 | index_last=max(index); |
---|
2055 | box_used=box_test([index_first : index_last]); |
---|
2056 | [box_missing,ind_missing]=min(box_used); |
---|
2057 | if isequal(box_missing,0) |
---|
2058 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
2059 | return |
---|
2060 | end |
---|
2061 | |
---|
2062 | %root name |
---|
2063 | filebase=get(handles.displ_filebase,'String'); |
---|
2064 | if isempty(filebase)||isequal(filebase,'') |
---|
2065 | msgbox_uvmat('ERROR','no input files') |
---|
2066 | return |
---|
2067 | end |
---|
2068 | |
---|
2069 | %check mask if selecetd |
---|
2070 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
2071 | maskname=get(handles.mask_civ1,'String'); |
---|
2072 | if ~exist(maskname,'file') |
---|
2073 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
2074 | end |
---|
2075 | end |
---|
2076 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
2077 | maskname=get(handles.mask_fix1,'String'); |
---|
2078 | if ~exist(maskname,'file') |
---|
2079 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
2080 | end |
---|
2081 | end |
---|
2082 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
2083 | maskname=get(handles.mask_civ2,'String'); |
---|
2084 | if ~exist(maskname,'file') |
---|
2085 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
2086 | end |
---|
2087 | end |
---|
2088 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
2089 | maskname=get(handles.mask_fix2,'String'); |
---|
2090 | if ~exist(maskname,'file') |
---|
2091 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
2092 | end |
---|
2093 | end |
---|
2094 | |
---|
2095 | %read names of the .exe file |
---|
2096 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
2097 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
2098 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
2099 | if exist(xmlfile,'file') |
---|
2100 | t=xmltree(xmlfile); |
---|
2101 | sparam=convert(t); |
---|
2102 | end |
---|
2103 | % else |
---|
2104 | % xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
2105 | % if exist(xmlfile,'file') |
---|
2106 | % t=xmltree(xmlfile); |
---|
2107 | % sparam=convert(t); |
---|
2108 | % end |
---|
2109 | % end |
---|
2110 | sge=0; |
---|
2111 | if isfield(sparam,'Civ_exe') |
---|
2112 | Civ_exe=sparam.Civ_exe; |
---|
2113 | end |
---|
2114 | if isfield(sparam,'Civ1_exe') |
---|
2115 | civ1_exe=sparam.Civ1_exe; |
---|
2116 | end |
---|
2117 | if isfield(sparam,'Civ2_exe') |
---|
2118 | civ2_exe=sparam.Civ2_exe; |
---|
2119 | end |
---|
2120 | if isfield(sparam,'Patch_exe') |
---|
2121 | patch_exe=sparam.Patch_exe; |
---|
2122 | end |
---|
2123 | if isfield(sparam,'PatchNew_exe') |
---|
2124 | patch_new_exe=sparam.PatchNew_exe; |
---|
2125 | end |
---|
2126 | if isfield(sparam,'Fix_exe') |
---|
2127 | fix_exe=sparam.Fix_exe; |
---|
2128 | end |
---|
2129 | if isfield(sparam,'Todo_path') |
---|
2130 | todo_path=sparam.Todo_path; |
---|
2131 | end |
---|
2132 | if isfield(sparam,'SGE') |
---|
2133 | sge=str2num(sparam.SGE); |
---|
2134 | end |
---|
2135 | |
---|
2136 | %choice of batch priority |
---|
2137 | ind_answer=2; |
---|
2138 | if sge |
---|
2139 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
2140 | if isequal(s,0) |
---|
2141 | w(end)=[]; |
---|
2142 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
2143 | str={'urgent';'normal';'low'}; |
---|
2144 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
2145 | 'SelectionMode','single',... |
---|
2146 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
2147 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
2148 | return % a better way should be create |
---|
2149 | end |
---|
2150 | else |
---|
2151 | msgbox_uvmat('ERROR','batch system not available') |
---|
2152 | return |
---|
2153 | end |
---|
2154 | end |
---|
2155 | |
---|
2156 | %initialize the waitbars |
---|
2157 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
2158 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
2159 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
2160 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
2161 | set(handles.BATCH, 'Enable','Off') |
---|
2162 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
2163 | drawnow |
---|
2164 | %get the filename root, nomenclature and numbers |
---|
2165 | |
---|
2166 | % for Windows system find the UBC path name if needed |
---|
2167 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
2168 | cur_dir=pwd; |
---|
2169 | if ~isequal(cur_dir(2:3),':\') |
---|
2170 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
2171 | end |
---|
2172 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
2173 | if isequal(ss,0) |
---|
2174 | rankpath=findstr(ww,'\\'); |
---|
2175 | if ~isempty(rankpath) |
---|
2176 | wwrest=ww(rankpath:end); |
---|
2177 | rankend=min(find(double(wwrest)==10))-1; |
---|
2178 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
2179 | set(handles.displ_filebase,'String',filebase); |
---|
2180 | end |
---|
2181 | else |
---|
2182 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
2183 | set(handles.BATCH, 'Enable','On') |
---|
2184 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2185 | return |
---|
2186 | end |
---|
2187 | end |
---|
2188 | |
---|
2189 | % set the list of files and check them |
---|
2190 | display('checking the files...') |
---|
2191 | [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]=... |
---|
2192 | set_civ_filenames(handles,compare,box_test); |
---|
2193 | |
---|
2194 | display('files OK, processing...') |
---|
2195 | nbfield=numel(num1_civ1); |
---|
2196 | nbslice=numel(num_a_civ1); |
---|
2197 | |
---|
2198 | %GET PARAMETERS: |
---|
2199 | %get civ parameters |
---|
2200 | if box_test(1)==1 |
---|
2201 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
2202 | end |
---|
2203 | |
---|
2204 | %get fix1 parameters |
---|
2205 | if box_test(2)==1 |
---|
2206 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
2207 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
2208 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
2209 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
2210 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
2211 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
2212 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
2213 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
2214 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
2215 | % fileref=get(handles.ref_fix1,'String'); |
---|
2216 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
2217 | % fileref=fullfile(refpath,fileref); |
---|
2218 | menu=get(handles.field_ref1,'String'); |
---|
2219 | index=get(handles.field_ref1,'Value'); |
---|
2220 | if isempty(menu) |
---|
2221 | fieldchoice=''; |
---|
2222 | else |
---|
2223 | fieldchoice=menu{index}; |
---|
2224 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
2225 | end |
---|
2226 | end |
---|
2227 | |
---|
2228 | %get patch1 parameters |
---|
2229 | if box_test(3)==1 |
---|
2230 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
2231 | if isempty(rho_patch1) |
---|
2232 | rho_patch1='1000'; |
---|
2233 | set(handles.rho_patch1,'String','1') |
---|
2234 | else |
---|
2235 | rho_patch1=num2str(1000*rho_patch1); |
---|
2236 | end |
---|
2237 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
2238 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
2239 | if isequal(str2num(nx_patch1),[]) |
---|
2240 | nx_patch1='50' ;%default |
---|
2241 | set(handles.nx_patch1,'String','50'); |
---|
2242 | end |
---|
2243 | if isequal(str2num(ny_patch1),[]) |
---|
2244 | ny_patch1='50' ;%default |
---|
2245 | set(handles.ny_patch1,'String','50'); |
---|
2246 | end |
---|
2247 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
2248 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
2249 | test_interp=get(handles.test_interp,'Value'); |
---|
2250 | end |
---|
2251 | |
---|
2252 | %get civ2 parameters |
---|
2253 | if box_test(4)==1 |
---|
2254 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
2255 | end |
---|
2256 | |
---|
2257 | %get fix2 parameters |
---|
2258 | if box_test(5)==1 |
---|
2259 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
2260 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
2261 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
2262 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
2263 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
2264 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
2265 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
2266 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
2267 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
2268 | % ref=get(handles.ref_fix2,'UserData'); |
---|
2269 | |
---|
2270 | %%%%%%%%%%%%%%%%%%% |
---|
2271 | end |
---|
2272 | |
---|
2273 | |
---|
2274 | %get patch2 parameters |
---|
2275 | if box_test(6)==1 |
---|
2276 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
2277 | if isempty(rho_patch2) |
---|
2278 | rho_patch2='1000'; |
---|
2279 | set(handles.rho_patch2,'String','1') |
---|
2280 | else |
---|
2281 | rho_patch2=num2str(1000*rho_patch2); |
---|
2282 | end |
---|
2283 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
2284 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
2285 | if isequal(str2num(nx_patch2),[]) |
---|
2286 | nx_patch2='50' ;%default |
---|
2287 | set(handles.nx_patch2,'String','50'); |
---|
2288 | end |
---|
2289 | if isequal(str2num(ny_patch2),[]) |
---|
2290 | ny_patch2='50' ;%default |
---|
2291 | set(handles.ny_patch2,'String','50'); |
---|
2292 | end |
---|
2293 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
2294 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
2295 | test_interp=get(handles.test_interp,'Value'); |
---|
2296 | end |
---|
2297 | |
---|
2298 | if ~sge |
---|
2299 | |
---|
2300 | %OPEN THE WAIT LIST FOR BATCH PROCESSES |
---|
2301 | name_lock=fullfile(todo_path,'lock'); %lock file |
---|
2302 | iwait=0; |
---|
2303 | while(exist(name_lock) & iwait<15) |
---|
2304 | pause(1); %wait 1 second |
---|
2305 | iwait=iwait+1; |
---|
2306 | end |
---|
2307 | if iwait==15 |
---|
2308 | msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) |
---|
2309 | set(handles.BATCH, 'Enable','On') |
---|
2310 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2311 | return |
---|
2312 | end |
---|
2313 | p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere |
---|
2314 | name_todo=fullfile(todo_path,'TODO.txt'); |
---|
2315 | p1=fopen(name_todo,'a'); |
---|
2316 | if (p1<0) |
---|
2317 | msgbox_uvmat('ERROR',['error in opening ' name_todo]) |
---|
2318 | set(handles.BATCH, 'Enable','On') |
---|
2319 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2320 | return; |
---|
2321 | end |
---|
2322 | end |
---|
2323 | |
---|
2324 | %MAIN LOOP |
---|
2325 | % for ifile=1:nbfield |
---|
2326 | p1text=[];%initiate command text |
---|
2327 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
2328 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
2329 | for ifile=1:nbfield |
---|
2330 | for j=1:nbslice |
---|
2331 | i_cmd=0; |
---|
2332 | cmd=''; |
---|
2333 | if sge |
---|
2334 | %fid=fopen([filename '.cmx'],'w') |
---|
2335 | cmd='#!/bin/bash'; |
---|
2336 | cmd=[cmd '\n' '#$ -cwd']; |
---|
2337 | cmd=[cmd '\n' 'hostname && date']; |
---|
2338 | end |
---|
2339 | if civAll |
---|
2340 | civAllxml=xmltree;% xml contents, all parameters |
---|
2341 | civAllCmd=[]; |
---|
2342 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
2343 | end |
---|
2344 | % filecell.nc.civ1 |
---|
2345 | filename_cmx=filecell.nc.civ1{ifile,j}%output netcdf file |
---|
2346 | filename_cmx(end-1:end)='cm';%name of cmx file |
---|
2347 | filename_cmx=[filename_cmx 'x']; |
---|
2348 | |
---|
2349 | %CIV1 |
---|
2350 | if box_test(1)==1 |
---|
2351 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
2352 | % par_civ1.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
2353 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
2354 | % par_civ1.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
2355 | |
---|
2356 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
2357 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
2358 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
2359 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
2360 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
2361 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
2362 | if test_mask==0 |
---|
2363 | par_civ1.maskname='noFile use default'; |
---|
2364 | par_civ1.maskflag='n'; |
---|
2365 | else |
---|
2366 | maskdispl=get(handles.mask_civ1,'String'); |
---|
2367 | if exist(maskdispl,'file') |
---|
2368 | par_civ1.maskname=maskdispl; |
---|
2369 | par_civ1.maskflag='y'; |
---|
2370 | else |
---|
2371 | maskbase=[filebase '_' maskdispl]; % |
---|
2372 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2373 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
2374 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2375 | if exist(par_civ1.maskname,'file') |
---|
2376 | par_civ1.maskflag='y'; |
---|
2377 | else |
---|
2378 | par_civ1.maskname='noFile use default'; |
---|
2379 | par_civ1.maskflag='n'; |
---|
2380 | end |
---|
2381 | end |
---|
2382 | end |
---|
2383 | |
---|
2384 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
2385 | if test_grid |
---|
2386 | par_civ1.gridflag='y'; |
---|
2387 | gridname=get(handles.grid_civ1,'String'); |
---|
2388 | if isequal(gridname(end-3:end),'grid') |
---|
2389 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2390 | if ~isempty(nbslice_grid) |
---|
2391 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
2392 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2393 | if ~exist(par_civ1.gridname,'file') |
---|
2394 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
2395 | end |
---|
2396 | elseif exist(gridname,'file') |
---|
2397 | par_civ1.gridname=gridname; |
---|
2398 | else |
---|
2399 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
2400 | end |
---|
2401 | end |
---|
2402 | else |
---|
2403 | par_civ1.gridname='noFile use default'; |
---|
2404 | par_civ1.gridflag='n'; |
---|
2405 | end |
---|
2406 | % |
---|
2407 | i_cmd=i_cmd+1; |
---|
2408 | if isequal(civAll,0) |
---|
2409 | cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles)]; |
---|
2410 | else |
---|
2411 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
2412 | str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
2413 | fieldnames=fields(str); |
---|
2414 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
2415 | for ilist=1:length(fieldnames) |
---|
2416 | val=eval(['str.' fieldnames{ilist}]); |
---|
2417 | if ischar(val) |
---|
2418 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
2419 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2420 | end |
---|
2421 | end |
---|
2422 | end |
---|
2423 | end |
---|
2424 | |
---|
2425 | % FIX1 |
---|
2426 | if box_test(2)==1 |
---|
2427 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
2428 | if test_mask==0 |
---|
2429 | maskname=''; |
---|
2430 | else |
---|
2431 | maskdispl=get(handles.mask_fix1,'String'); |
---|
2432 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2433 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
2434 | maskbase=[filebase '_' maskdispl]; |
---|
2435 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2436 | end |
---|
2437 | if isequal(civAll,0) |
---|
2438 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
2439 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
2440 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
2441 | cmd=[cmd '\n' cmd_FIX]; |
---|
2442 | else |
---|
2443 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
2444 | fix1.fi1=num2str(flagindex1(1)); |
---|
2445 | fix1.fi2=num2str(flagindex1(2)); |
---|
2446 | fix1.fi3=num2str(flagindex1(3)); |
---|
2447 | fix1.threshC=num2str(thresh_vecC1); |
---|
2448 | fix1.threshV=num2str(thresh_vel1); |
---|
2449 | fieldnames=fields(fix1); |
---|
2450 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
2451 | for ilist=1:length(fieldnames) |
---|
2452 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
2453 | if ischar(val) |
---|
2454 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
2455 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2456 | end |
---|
2457 | end |
---|
2458 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
2459 | end |
---|
2460 | end |
---|
2461 | |
---|
2462 | %PATCH1 |
---|
2463 | if box_test(3)==1 |
---|
2464 | if isequal(civAll,0) |
---|
2465 | cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
2466 | cmd=[cmd '\n' cmd_PATCH]; |
---|
2467 | else |
---|
2468 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
2469 | patch1.nopt=subdomain_patch1; |
---|
2470 | patch1.maxdiff=thresh_patch1; |
---|
2471 | patch1.ro=rho_patch1; |
---|
2472 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
2473 | if test_grid |
---|
2474 | patch1.gridflag='y'; |
---|
2475 | gridname=get(handles.grid_patch1,'String'); |
---|
2476 | if isequal(gridname(end-3:end),'grid') |
---|
2477 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2478 | if ~isempty(nbslice_grid) |
---|
2479 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
2480 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2481 | if ~exist(patch1.gridPatch,'file') |
---|
2482 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
2483 | end |
---|
2484 | elseif exist(gridname,'file') |
---|
2485 | patch1.gridPatch=gridname; |
---|
2486 | else |
---|
2487 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
2488 | end |
---|
2489 | end |
---|
2490 | else |
---|
2491 | patch1.gridPatch='n'; |
---|
2492 | patch1.gridflag='n'; |
---|
2493 | patch1.m=nx_patch1; |
---|
2494 | patch1.n=ny_patch1; |
---|
2495 | end |
---|
2496 | patch1.convectFlow='n'; |
---|
2497 | fieldnames=fields(patch1); |
---|
2498 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
2499 | for ilist=1:length(fieldnames) |
---|
2500 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
2501 | if ischar(val) |
---|
2502 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
2503 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2504 | end |
---|
2505 | end |
---|
2506 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
2507 | end |
---|
2508 | end |
---|
2509 | |
---|
2510 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
2511 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
2512 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
2513 | filename_cmx=[filename_cmx 'x']; |
---|
2514 | end |
---|
2515 | |
---|
2516 | if box_test(4)==1 |
---|
2517 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
2518 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
2519 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
2520 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
2521 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
2522 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
2523 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
2524 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
2525 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
2526 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
2527 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
2528 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
2529 | if test_mask==0 |
---|
2530 | par_civ2.maskname='noFile use default'; |
---|
2531 | par_civ2.maskflag='n'; |
---|
2532 | else |
---|
2533 | maskdispl=get(handles.mask_civ2,'String'); |
---|
2534 | if exist(maskdispl,'file') |
---|
2535 | par_civ2.maskname=maskdispl; |
---|
2536 | par_civ2.maskflag='y'; |
---|
2537 | else |
---|
2538 | maskbase=[filebase '_' maskdispl]; % |
---|
2539 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2540 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
2541 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2542 | if exist(par_civ2.maskname,'file') |
---|
2543 | par_civ2.maskflag='y'; |
---|
2544 | else |
---|
2545 | par_civ2.maskname='noFile use default'; |
---|
2546 | par_civ2.maskflag='n'; |
---|
2547 | end |
---|
2548 | end |
---|
2549 | end |
---|
2550 | %TESTgrid |
---|
2551 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
2552 | gridname=get(handles.grid_civ2,'String'); |
---|
2553 | gridflag='y'; |
---|
2554 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
2555 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2556 | if ~isempty(nbslice_grid) |
---|
2557 | par_civ2.gridflag='y'; |
---|
2558 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
2559 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2560 | if exist(par_civ2.gridname,'file') |
---|
2561 | par_civ2.gridflag='y'; |
---|
2562 | else |
---|
2563 | par_civ2.gridname='noFile use default'; |
---|
2564 | par_civ2.gridflag='n'; |
---|
2565 | end |
---|
2566 | elseif exist(gridname,'file') |
---|
2567 | par_civ2.gridflag='y'; |
---|
2568 | else |
---|
2569 | par_civ2.gridname='noFile use default'; |
---|
2570 | par_civ2.gridflag='n'; |
---|
2571 | end |
---|
2572 | end |
---|
2573 | %endTESTgrid |
---|
2574 | i_cmd=i_cmd+1; |
---|
2575 | cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2); |
---|
2576 | if isequal(civAll,0) |
---|
2577 | if(isunix) |
---|
2578 | cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
2579 | else |
---|
2580 | cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
2581 | end |
---|
2582 | else |
---|
2583 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
2584 | str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2); |
---|
2585 | fieldnames=fields(str); |
---|
2586 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
2587 | for ilist=1:length(fieldnames) |
---|
2588 | val=eval(['str.' fieldnames{ilist}]); |
---|
2589 | if ischar(val) |
---|
2590 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
2591 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2592 | end |
---|
2593 | end |
---|
2594 | end |
---|
2595 | end |
---|
2596 | |
---|
2597 | % FIX2 |
---|
2598 | if box_test(5)==1 |
---|
2599 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
2600 | if test_mask==0 |
---|
2601 | maskname=''; %no mask used |
---|
2602 | else |
---|
2603 | maskdispl=get(handles.mask_fix2,'String'); |
---|
2604 | maskbase=[filebase '_' maskdispl]; % |
---|
2605 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2606 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
2607 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2608 | end |
---|
2609 | if isequal(civAll,0) |
---|
2610 | cmd_FIX=[fix_exe ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
2611 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
2612 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
2613 | cmd=[cmd '\n' cmd_FIX]; |
---|
2614 | else |
---|
2615 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
2616 | fix2.fi1=num2str(flagindex2(1)); |
---|
2617 | fix2.fi2=num2str(flagindex2(2)); |
---|
2618 | fix2.fi3=num2str(flagindex2(3)); |
---|
2619 | fix2.threshC=num2str(thresh_vec2C); |
---|
2620 | fix2.threshV=num2str(thresh_vel2); |
---|
2621 | fieldnames=fields(fix2); |
---|
2622 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
2623 | for ilist=1:length(fieldnames) |
---|
2624 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
2625 | if ischar(val) |
---|
2626 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
2627 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2628 | end |
---|
2629 | end |
---|
2630 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
2631 | end |
---|
2632 | end |
---|
2633 | |
---|
2634 | %PATCH2 |
---|
2635 | if box_test(6)==1 |
---|
2636 | if isequal(civAll,0) |
---|
2637 | cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp); |
---|
2638 | cmd=[cmd '\n' cmd_PATCH]; |
---|
2639 | else |
---|
2640 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
2641 | patch2.nopt=subdomain_patch1; |
---|
2642 | patch2.maxdiff=thresh_patch1; |
---|
2643 | patch2.ro=rho_patch1; |
---|
2644 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
2645 | if test_grid |
---|
2646 | patch2.gridflag='y'; |
---|
2647 | gridname=get(handles.grid_patch2,'String'); |
---|
2648 | if isequal(gridname(end-3:end),'grid') |
---|
2649 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2650 | if ~isempty(nbslice_grid) |
---|
2651 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
2652 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2653 | if ~exist(patch2.gridPatch,'file') |
---|
2654 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
2655 | end |
---|
2656 | elseif exist(gridname,'file') |
---|
2657 | patch2.gridPatch=gridname; |
---|
2658 | else |
---|
2659 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
2660 | end |
---|
2661 | end |
---|
2662 | else |
---|
2663 | patch2.gridPatch='n'; |
---|
2664 | patch2.gridflag='n'; |
---|
2665 | patch2.m=nx_patch2; |
---|
2666 | patch2.n=ny_patch2; |
---|
2667 | end |
---|
2668 | patch2.convectFlow='n'; |
---|
2669 | fieldnames=fields(patch2); |
---|
2670 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
2671 | for ilist=1:length(fieldnames) |
---|
2672 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
2673 | if ischar(val) |
---|
2674 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
2675 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2676 | end |
---|
2677 | end |
---|
2678 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
2679 | end |
---|
2680 | end |
---|
2681 | if isequal(civAll,1) |
---|
2682 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
2683 | cmd=char({cmd;[Civ_exe ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
2684 | end |
---|
2685 | % create the .bat file: |
---|
2686 | if sge |
---|
2687 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
2688 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
2689 | else |
---|
2690 | filename_bat=filename_cmx; |
---|
2691 | end |
---|
2692 | filename_bat(end-2:end)='bat'; |
---|
2693 | fid=fopen(filename_bat,'w'); |
---|
2694 | fprintf(fid,cmd); |
---|
2695 | fclose(fid); |
---|
2696 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
2697 | if sge |
---|
2698 | pvalue=num2str((1-ind_answer)*500); |
---|
2699 | namelog=[filename_bat '.patch.log']; |
---|
2700 | ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; |
---|
2701 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
2702 | else |
---|
2703 | if(isunix) |
---|
2704 | cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; |
---|
2705 | else |
---|
2706 | cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; |
---|
2707 | end |
---|
2708 | count= fprintf(p1,'%s\n', cmdtodo); |
---|
2709 | end |
---|
2710 | end |
---|
2711 | end |
---|
2712 | if ~sge |
---|
2713 | fclose(p1); |
---|
2714 | fclose(p0); |
---|
2715 | delete(name_lock); |
---|
2716 | end |
---|
2717 | |
---|
2718 | set(handles.BATCH, 'Enable','On') |
---|
2719 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2720 | |
---|
2721 | %save interface state |
---|
2722 | if isfield(filecell,'nc') |
---|
2723 | if isfield(filecell.nc,'civ2') |
---|
2724 | fileresu=filecell.nc.civ2{1,1}; |
---|
2725 | else |
---|
2726 | fileresu=filecell.nc.civ1{1,1}; |
---|
2727 | end |
---|
2728 | end |
---|
2729 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
2730 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
2731 | detect=1; |
---|
2732 | while detect==1 |
---|
2733 | namefigfull=[namedoc '.fig']; |
---|
2734 | hh=dir(namefigfull); |
---|
2735 | if ~isempty(hh) |
---|
2736 | detect=1; |
---|
2737 | namedoc=[namedoc '.0']; |
---|
2738 | else |
---|
2739 | detect=0; |
---|
2740 | end |
---|
2741 | end |
---|
2742 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
2743 | |
---|
2744 | %------------------------------------------------------------------------ |
---|
2745 | %OUTPUT: |
---|
2746 | % filecell: structure of input and output files |
---|
2747 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
2748 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
2749 | % .imaA1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2, with camA in stereo case (then .ima1 corresponds to camB) |
---|
2750 | % .imaA2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations, with camA in stereo case (then .ima1 corresponds to camB) |
---|
2751 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
2752 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
2753 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
2754 | % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1 |
---|
2755 | % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1 |
---|
2756 | % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2 |
---|
2757 | % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2 |
---|
2758 | % nom_type_nc: nomenclature type for velocity files |
---|
2759 | % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2 |
---|
2760 | 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]=... |
---|
2761 | set_civ_filenames(handles,compare,box_test) |
---|
2762 | %------------------------------------------------------------------------ |
---|
2763 | %get the filename root, nomenclature and numbers |
---|
2764 | filebase=get(handles.displ_filebase,'String'); |
---|
2765 | browse=get(handles.browse_root,'UserData'); |
---|
2766 | compare_list=get(handles.compare,'String'); |
---|
2767 | val=get(handles.compare,'Value'); |
---|
2768 | compare=compare_list{val}; |
---|
2769 | if strcmp(compare,'displacement') |
---|
2770 | mode='displacement'; |
---|
2771 | else |
---|
2772 | mode_list=get(handles.mode,'String'); |
---|
2773 | mode_value=get(handles.mode,'Value'); |
---|
2774 | mode=mode_list{mode_value}; |
---|
2775 | end |
---|
2776 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
2777 | ext_ima=get(handles.ext_ima,'String'); |
---|
2778 | nom_type_nc=browse.nom_type_nc; |
---|
2779 | nom_type_ima2=browse.nom_type_ima; |
---|
2780 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
2781 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
2782 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
2783 | find_pair_indices(handles,mode); |
---|
2784 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
2785 | filebase_B=filebase;% root name of the second field series for stereo |
---|
2786 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
2787 | test_disp=1; |
---|
2788 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
2789 | [Path2,Name2]=fileparts(filebase_B); |
---|
2790 | Path1=Path2; |
---|
2791 | Name1=get(handles.displ_filebase2,'String');% root name of the first field series for stereo |
---|
2792 | filebase_A=fullfile(Path1,Name1); |
---|
2793 | if length(Name1)>6 |
---|
2794 | Name1=Name1(end-5:end); |
---|
2795 | end |
---|
2796 | if length(Name2)>6 |
---|
2797 | Name2=Name2(end-5:end); |
---|
2798 | end |
---|
2799 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
2800 | else |
---|
2801 | test_disp=0; |
---|
2802 | filebase_A=filebase; |
---|
2803 | nom_type_ima1=nom_type_ima2; |
---|
2804 | filebase_AB=filebase; |
---|
2805 | end |
---|
2806 | if strcmp(compare,'displacement') |
---|
2807 | filebase_ima1=filebase_A; |
---|
2808 | filebase_ima2=filebase_B; |
---|
2809 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
2810 | else |
---|
2811 | filebase_ima1=filebase_B; |
---|
2812 | filebase_ima2=filebase_B; |
---|
2813 | filebase_nc=filebase_B; |
---|
2814 | end |
---|
2815 | |
---|
2816 | %determine reference files for fix: |
---|
2817 | file_ref_fix1={};%default |
---|
2818 | file_ref_fix2={}; |
---|
2819 | nbfield=length(num1_civ1); |
---|
2820 | nbslice=length(num_a_civ1); |
---|
2821 | if box_test(2)==1% fix1 performed |
---|
2822 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
2823 | if ~isempty(ref) |
---|
2824 | first_i=str2num(get(handles.first_i,'String')); |
---|
2825 | last_i=str2num(get(handles.last_i,'String')); |
---|
2826 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
2827 | first_j=str2num(get(handles.first_j,'String')); |
---|
2828 | last_j=str2num(get(handles.last_j,'String')); |
---|
2829 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
2830 | num_i_ref=[first_i:incr_i:last_i]; |
---|
2831 | num_j_ref=[first_j:incr_j:last_j]; |
---|
2832 | if isequal(mode,'displacement') |
---|
2833 | num_i1=num_i_ref; |
---|
2834 | num_i2=num_i_ref; |
---|
2835 | num_j1=num_j_ref; |
---|
2836 | num_j2=num_j_ref; |
---|
2837 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
2838 | num_i1=num_i_ref; |
---|
2839 | num_i2=num_i1; |
---|
2840 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
2841 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
2842 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
2843 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2844 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2845 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2846 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2847 | if isempty(ref.num_a) |
---|
2848 | ref.num_a=1; |
---|
2849 | end |
---|
2850 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2851 | num_j2=num_j1; |
---|
2852 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
2853 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2854 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2855 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2856 | num_i2=num_i1; |
---|
2857 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2858 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2859 | end |
---|
2860 | for ifile=1:nbfield |
---|
2861 | for j=1:nbslice |
---|
2862 | 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);% |
---|
2863 | file_ref_fix1(ifile,j)={file_ref}; |
---|
2864 | if ~exist(file_ref,'file') |
---|
2865 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
2866 | filecell=[]; |
---|
2867 | return |
---|
2868 | end |
---|
2869 | end |
---|
2870 | end |
---|
2871 | end |
---|
2872 | end |
---|
2873 | |
---|
2874 | %determine reference files for fix2: |
---|
2875 | if box_test(5)==1% fix2 performed |
---|
2876 | ref=get(handles.ref_fix2,'UserData'); |
---|
2877 | if ~isempty(ref) |
---|
2878 | first_i=str2num(get(handles.first_i,'String')); |
---|
2879 | last_i=str2num(get(handles.last_i,'String')); |
---|
2880 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
2881 | first_j=str2num(get(handles.first_j,'String')); |
---|
2882 | last_j=str2num(get(handles.last_j,'String')); |
---|
2883 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
2884 | num_i_ref=[first_i:incr_i:last_i]; |
---|
2885 | num_j_ref=[first_j:incr_j:last_j]; |
---|
2886 | if isequal(mode,'displacement') |
---|
2887 | num_i1=num_i_ref; |
---|
2888 | num_i2=num_i_ref; |
---|
2889 | num_j1=num_j_ref; |
---|
2890 | num_j2=num_j_ref; |
---|
2891 | elseif isequal(mode,'pair j1-j2') |
---|
2892 | num_i1=num_i_ref; |
---|
2893 | num_i2=num_i1; |
---|
2894 | num_j1=ref.num_a; |
---|
2895 | num_j2=ref.num_b; |
---|
2896 | elseif isequal(mode,'series(Di)') |
---|
2897 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2898 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2899 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2900 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2901 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2902 | num_j2=num_j1; |
---|
2903 | elseif isequal(mode,'series(Dj)') |
---|
2904 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2905 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2906 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2907 | num_i2=num_i1; |
---|
2908 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2909 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2910 | end |
---|
2911 | for ifile=1:nbfield |
---|
2912 | for j=1:nbslice |
---|
2913 | 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);% |
---|
2914 | file_ref_fix2(ifile,j)={file_ref}; |
---|
2915 | if ~exist(file_ref,'file') |
---|
2916 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
2917 | filecell=[]; |
---|
2918 | return |
---|
2919 | end |
---|
2920 | end |
---|
2921 | end |
---|
2922 | end |
---|
2923 | end |
---|
2924 | |
---|
2925 | %check dir |
---|
2926 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
2927 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
2928 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
2929 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
2930 | currentdir=pwd;%store the current working directory |
---|
2931 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
2932 | if ~exist(Path_ima,'dir') |
---|
2933 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
2934 | filecell=[]; |
---|
2935 | return |
---|
2936 | end |
---|
2937 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
2938 | dircur=pwd; %current working directory |
---|
2939 | m2=''; |
---|
2940 | [erread,message]=fileattrib(Path_ima); |
---|
2941 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
2942 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
2943 | filecell=[]; |
---|
2944 | cd(currentdir); |
---|
2945 | return |
---|
2946 | end |
---|
2947 | |
---|
2948 | %check the existence of the netcdf and image files involved |
---|
2949 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
2950 | if box_test(1)==1; |
---|
2951 | detect=1; |
---|
2952 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
2953 | for ifile=1:nbfield; |
---|
2954 | for j=1:nbslice |
---|
2955 | 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); |
---|
2956 | detect=exist(filename,'file')==2; |
---|
2957 | if detect% if a netcdf file already exists |
---|
2958 | subdir_civ1=[subdir_civ1 '.0']; |
---|
2959 | subdir_civ2=subdir_civ1; |
---|
2960 | break |
---|
2961 | end |
---|
2962 | filecell.nc.civ1(ifile,j)={filename}; |
---|
2963 | end |
---|
2964 | if detect% if a netcdf file already exists |
---|
2965 | break |
---|
2966 | end |
---|
2967 | end |
---|
2968 | %create the new subdir_civ1 |
---|
2969 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
2970 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
2971 | if ~isequal(m2,'') |
---|
2972 | msgbox_uvmat('ERROR', m2) |
---|
2973 | %msgbox(m2);%error message for directory creation |
---|
2974 | end |
---|
2975 | end |
---|
2976 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
2977 | for ifile=1:nbfield |
---|
2978 | for j=1:nbslice |
---|
2979 | 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);% |
---|
2980 | detect=exist(filename,'file')==2; |
---|
2981 | if detect% if a netcdf file already exists |
---|
2982 | subdir_civ1=[subdir_civ1 '.0']; |
---|
2983 | subdir_civ2=subdir_civ1; |
---|
2984 | break |
---|
2985 | end |
---|
2986 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
2987 | end |
---|
2988 | if detect% if a netcdf file already exists |
---|
2989 | break |
---|
2990 | end |
---|
2991 | end |
---|
2992 | %create the new subdir_civ1 |
---|
2993 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
2994 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
2995 | if ~isequal(m2,'') |
---|
2996 | msgbox_uvmat('ERROR', m2) |
---|
2997 | end |
---|
2998 | end |
---|
2999 | end |
---|
3000 | end |
---|
3001 | % get image names |
---|
3002 | for ifile=1:nbfield |
---|
3003 | for j=1:nbslice |
---|
3004 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
3005 | idetect(j)=exist(filename,'file')==2; |
---|
3006 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
3007 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
3008 | idetect_1(j)=exist(filename,'file')==2; |
---|
3009 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
3010 | end |
---|
3011 | [idetectmin,indexj]=min(idetect); |
---|
3012 | if idetectmin==0, |
---|
3013 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
3014 | filecell=[]; |
---|
3015 | return |
---|
3016 | end |
---|
3017 | [idetectmin,indexj]=min(idetect_1); |
---|
3018 | if idetectmin==0, |
---|
3019 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
3020 | filecell=[]; |
---|
3021 | cd(currentdir) |
---|
3022 | return |
---|
3023 | end |
---|
3024 | end |
---|
3025 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
3026 | for ifile=1:nbfield |
---|
3027 | for j=1:nbslice |
---|
3028 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
3029 | idetect(j)=exist(filename,'file')==2; |
---|
3030 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
3031 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
3032 | idetect_1(j)=exist(filename,'file')==2; |
---|
3033 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
3034 | end |
---|
3035 | [idetectmin,indexj]=min(idetect); |
---|
3036 | if idetectmin==0, |
---|
3037 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
3038 | filecell=[]; |
---|
3039 | cd(currentdir) |
---|
3040 | return |
---|
3041 | end |
---|
3042 | [idetectmin,indexj]=min(idetect_1); |
---|
3043 | if idetectmin==0, |
---|
3044 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
3045 | filecell=[]; |
---|
3046 | cd(currentdir) |
---|
3047 | return |
---|
3048 | end |
---|
3049 | end |
---|
3050 | end |
---|
3051 | |
---|
3052 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
3053 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
3054 | for ifile=1:nbfield |
---|
3055 | for j=1:nbslice |
---|
3056 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
3057 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
3058 | detect=exist(filename,'file')==2; |
---|
3059 | filecell.nc.civ1(ifile,j)={filename}; |
---|
3060 | end |
---|
3061 | end |
---|
3062 | if strcmp(compare,'stereo PIV') |
---|
3063 | for ifile=1:nbfield |
---|
3064 | for j=1:nbslice |
---|
3065 | 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);% |
---|
3066 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
3067 | if ~exist(filename,'file') |
---|
3068 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3069 | set(handles.RUN, 'Enable','On') |
---|
3070 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
3071 | set(handles.BATCH, 'Enable','On') |
---|
3072 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
3073 | filecell=[]; |
---|
3074 | cd(currentdir) |
---|
3075 | return |
---|
3076 | end |
---|
3077 | end |
---|
3078 | end |
---|
3079 | end |
---|
3080 | end |
---|
3081 | |
---|
3082 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
3083 | testdiff=0; |
---|
3084 | if (box_test(4)==1)&&... |
---|
3085 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
3086 | testdiff=1; |
---|
3087 | detect=1; |
---|
3088 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
3089 | for ifile=1:nbfield |
---|
3090 | for j=1:nbslice |
---|
3091 | 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);% |
---|
3092 | detect=exist(filename,'file')==2; |
---|
3093 | if detect% if a netcdf file already exists |
---|
3094 | subdir_civ2=[subdir_civ2 '.0']; |
---|
3095 | break |
---|
3096 | end |
---|
3097 | filecell.nc.civ2(ifile,j)={filename}; |
---|
3098 | end |
---|
3099 | if detect% if a netcdf file already exists |
---|
3100 | break |
---|
3101 | end |
---|
3102 | end |
---|
3103 | %create the new subdir_civ2 |
---|
3104 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
3105 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
3106 | if ~isequal(m2,'') |
---|
3107 | msgbox_uvmat('ERROR', m2) |
---|
3108 | end |
---|
3109 | end |
---|
3110 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
3111 | for ifile=1:nbfield |
---|
3112 | for j=1:nbslice |
---|
3113 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3114 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
3115 | detect=exist(filename,'file')==2; |
---|
3116 | if detect% if a netcdf file already exists |
---|
3117 | subdir_civ2=[subdir_civ2 '.0']; |
---|
3118 | break |
---|
3119 | end |
---|
3120 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
3121 | end |
---|
3122 | if detect% if a netcdf file already exists |
---|
3123 | break |
---|
3124 | end |
---|
3125 | end |
---|
3126 | %create the new subdir_civ1 |
---|
3127 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
3128 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
3129 | if ~isequal(m2,'') |
---|
3130 | msgbox_uvmat('ERROR', m2) |
---|
3131 | %msgbox(m2);%error message for directory creation |
---|
3132 | end |
---|
3133 | end |
---|
3134 | end |
---|
3135 | end |
---|
3136 | end |
---|
3137 | cd(currentdir);%come back to the current working directory |
---|
3138 | |
---|
3139 | |
---|
3140 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
3141 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
3142 | %check source netcdf file of civ1 estimates |
---|
3143 | if box_test(1)==0; %no civ1 performed |
---|
3144 | for ifile=1:nbfield |
---|
3145 | for j=1:nbslice |
---|
3146 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
3147 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
3148 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
3149 | if ~exist(filename,'file') |
---|
3150 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3151 | filecell=[]; |
---|
3152 | return |
---|
3153 | end |
---|
3154 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
3155 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
3156 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
3157 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
3158 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
3159 | filecell=[]; |
---|
3160 | return |
---|
3161 | end |
---|
3162 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
3163 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
3164 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
3165 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
3166 | filecell=[]; |
---|
3167 | return |
---|
3168 | end |
---|
3169 | end |
---|
3170 | end |
---|
3171 | end |
---|
3172 | end |
---|
3173 | if strcmp(compare,'stereo PIV') |
---|
3174 | for ifile=1:nbfield |
---|
3175 | for j=1:nbslice |
---|
3176 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3177 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
3178 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
3179 | if ~exist(filename,'file') |
---|
3180 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3181 | set(handles.RUN, 'Enable','On') |
---|
3182 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
3183 | set(handles.BATCH, 'Enable','On') |
---|
3184 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
3185 | cd(currentdir) |
---|
3186 | return |
---|
3187 | end |
---|
3188 | end |
---|
3189 | end |
---|
3190 | end |
---|
3191 | end |
---|
3192 | |
---|
3193 | detect=1; |
---|
3194 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
3195 | for ifile=1:nbfield |
---|
3196 | for j=1:nbslice |
---|
3197 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3198 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
3199 | detect=exist(filename,'file')==2; |
---|
3200 | filecell.nc.civ2(ifile,j)={filename}; |
---|
3201 | end |
---|
3202 | end |
---|
3203 | %get first image names for civ2 |
---|
3204 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
3205 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
3206 | elseif box_test(4)==1 |
---|
3207 | for ifile=1:nbfield |
---|
3208 | for j=1:nbslice |
---|
3209 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
3210 | idetect_2(j)=exist(filename,'file')==2; |
---|
3211 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
3212 | end |
---|
3213 | [idetectmin,indexj]=min(idetect_2); |
---|
3214 | if idetectmin==0, |
---|
3215 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
3216 | filecell=[]; |
---|
3217 | return |
---|
3218 | end |
---|
3219 | end |
---|
3220 | end |
---|
3221 | |
---|
3222 | %get second image names for civ2 |
---|
3223 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
3224 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
3225 | elseif box_test(4)==1 |
---|
3226 | for ifile=1:nbfield |
---|
3227 | for j=1:nbslice |
---|
3228 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
3229 | idetect_3(j)=exist(filename,'file')==2; |
---|
3230 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
3231 | end |
---|
3232 | [idetectmin,indexj]=min(idetect_3); |
---|
3233 | if idetectmin==0, |
---|
3234 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
3235 | filecell=[]; |
---|
3236 | return |
---|
3237 | end |
---|
3238 | end |
---|
3239 | end |
---|
3240 | end |
---|
3241 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
3242 | if ~testdiff |
---|
3243 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
3244 | else % check the civ2 files |
---|
3245 | for ifile=1:nbfield |
---|
3246 | for j=1:nbslice |
---|
3247 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3248 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
3249 | filecell.nc.civ2(ifile,j)={filename}; |
---|
3250 | if ~exist(filename,'file') |
---|
3251 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3252 | filecell=[]; |
---|
3253 | return |
---|
3254 | else |
---|
3255 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
3256 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
3257 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
3258 | filecell=[]; |
---|
3259 | return |
---|
3260 | end |
---|
3261 | end |
---|
3262 | end |
---|
3263 | end |
---|
3264 | end |
---|
3265 | end |
---|
3266 | |
---|
3267 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
3268 | if strcmp(compare,'stereo PIV') |
---|
3269 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
3270 | for ifile=1:nbfield |
---|
3271 | for j=1:nbslice |
---|
3272 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
3273 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
3274 | filecell.st(ifile,j)={filename}; |
---|
3275 | end |
---|
3276 | end |
---|
3277 | end |
---|
3278 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
3279 | for ifile=1:nbfield |
---|
3280 | for j=1:nbslice |
---|
3281 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3282 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
3283 | filecell.st(ifile,j)={filename}; |
---|
3284 | end |
---|
3285 | end |
---|
3286 | end |
---|
3287 | end |
---|
3288 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
3289 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
3290 | browse.nom_type_nc=nom_type_nc; |
---|
3291 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
3292 | |
---|
3293 | |
---|
3294 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
3295 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
3296 | nom_type_imanew1='_i'; |
---|
3297 | else |
---|
3298 | nom_type_imanew1=nom_type_ima1; |
---|
3299 | end |
---|
3300 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
3301 | nom_type_imanew2='_i'; |
---|
3302 | else |
---|
3303 | nom_type_imanew2=nom_type_ima2; |
---|
3304 | end |
---|
3305 | if ~isequal(ext_ima,'.png') |
---|
3306 | %%type of image file |
---|
3307 | type_ima1='none';%default |
---|
3308 | movieobject1=[];%default |
---|
3309 | if isequal(lower(ext_ima),'.avi') |
---|
3310 | hhh=which('mmreader'); |
---|
3311 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
3312 | type_ima1='movie'; |
---|
3313 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
3314 | else |
---|
3315 | type_ima1='avi'; |
---|
3316 | end |
---|
3317 | else |
---|
3318 | form=imformats(ext_ima(2:end)); |
---|
3319 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
3320 | if isequal(nom_type_ima1,'*'); |
---|
3321 | type_ima1='multimage';%image series in a single image file |
---|
3322 | else |
---|
3323 | type_ima1='image'; |
---|
3324 | end |
---|
3325 | end |
---|
3326 | end |
---|
3327 | type_ima2='none';%default |
---|
3328 | movieobject2=[]; |
---|
3329 | if isequal(lower(ext_ima),'.avi') |
---|
3330 | hhh=which('mmreader'); |
---|
3331 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
3332 | type_ima2='movie'; |
---|
3333 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
3334 | else |
---|
3335 | type_ima2='avi'; |
---|
3336 | end |
---|
3337 | else |
---|
3338 | form=imformats(ext_ima(2:end)); |
---|
3339 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
3340 | if isequal(nom_type_ima1,'*'); |
---|
3341 | type_ima2='multimage';%image series in a single image file |
---|
3342 | else |
---|
3343 | type_ima2='image'; |
---|
3344 | end |
---|
3345 | end |
---|
3346 | end |
---|
3347 | %npxy=get(handles.ext_ima,'UserData'); |
---|
3348 | % % if numel(npxy)<2 |
---|
3349 | % |
---|
3350 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ext_ima,nom_type_ima1); |
---|
3351 | % A=imread(filename); |
---|
3352 | % npxy=size(A); |
---|
3353 | % % end |
---|
3354 | % npy=npxy(1); |
---|
3355 | % npx=npxy(2); |
---|
3356 | if box_test(1)==1 %if civ1 is performed |
---|
3357 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
3358 | for ifile=1:nbfield |
---|
3359 | waitbar(ifile/nbfield); |
---|
3360 | for j=1:nbslice |
---|
3361 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
3362 | if ~exist(filename,'file') |
---|
3363 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
3364 | imwrite(A,filename,'BitDepth',16); |
---|
3365 | end |
---|
3366 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
3367 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
3368 | if ~exist(filename,'file') |
---|
3369 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
3370 | imwrite(A,filename,'BitDepth',16); |
---|
3371 | end |
---|
3372 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
3373 | end |
---|
3374 | end |
---|
3375 | close(h) |
---|
3376 | end |
---|
3377 | if box_test(4)==1 %if civ2 is performed |
---|
3378 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
3379 | for ifile=1:nbfield |
---|
3380 | waitbar(ifile/nbfield); |
---|
3381 | for j=1:nbslice |
---|
3382 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
3383 | if ~exist(filename,'file') |
---|
3384 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,num1_civ2(ifile)); |
---|
3385 | imwrite(A,filename,'BitDepth',16); |
---|
3386 | end |
---|
3387 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
3388 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
3389 | if ~exist(filename,'file') |
---|
3390 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,num2.civ1(ifile)); |
---|
3391 | imwrite(A,filename,'BitDepth',16); |
---|
3392 | end |
---|
3393 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
3394 | end |
---|
3395 | end |
---|
3396 | close(h); |
---|
3397 | end |
---|
3398 | end |
---|
3399 | |
---|
3400 | %------------------------------------------------------------------------ |
---|
3401 | %CIV1 CIV1 CIV1 CIV1 |
---|
3402 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
3403 | %------------------------------------------------------------------------ |
---|
3404 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
3405 | global civ1_exe sge%name of the executable for civ1 calculation |
---|
3406 | |
---|
3407 | %get civ parameters |
---|
3408 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
3409 | if isempty(ibx_val) |
---|
3410 | ibx='21'; set(handles.ibx,'String','21') |
---|
3411 | else |
---|
3412 | ibx=num2str(ibx_val); |
---|
3413 | end |
---|
3414 | iby_val=str2num(get(handles.iby,'String')); |
---|
3415 | if isempty(iby_val) |
---|
3416 | iby='21'; set(handles.iby,'String','21') |
---|
3417 | else |
---|
3418 | iby=num2str(iby_val); |
---|
3419 | end |
---|
3420 | isx=get(handles.isx,'String'); |
---|
3421 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
3422 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
3423 | isy=get(handles.isy,'String'); |
---|
3424 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
3425 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
3426 | shiftx=get(handles.shiftx,'String'); |
---|
3427 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
3428 | shifty=get(handles.shifty,'String'); |
---|
3429 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
3430 | rho=get(handles.rho,'String'); |
---|
3431 | dx=get(handles.dx_civ1,'String'); |
---|
3432 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
3433 | dy=get(handles.dy_civ1,'String'); |
---|
3434 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
3435 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
3436 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
3437 | pxcmy='1'; |
---|
3438 | image_first=cell2mat(filecell(1,1)); |
---|
3439 | if ~exist(image_first,'file') |
---|
3440 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
3441 | set(handles.RUN, 'Enable','On') |
---|
3442 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
3443 | return |
---|
3444 | end |
---|
3445 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
3446 | sizim=size(A); |
---|
3447 | npx=num2str(sizim(2)); |
---|
3448 | npy=num2str(sizim(1)); |
---|
3449 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
3450 | gridname='';%default ='noFile use default' |
---|
3451 | gridflag='n';%default |
---|
3452 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
3453 | nbslice_grid=[]; |
---|
3454 | if test_grid |
---|
3455 | gridname=get(handles.grid_civ1,'String'); |
---|
3456 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
3457 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
3458 | if ~isempty(nbslice_grid) |
---|
3459 | gridflag='y'; |
---|
3460 | end |
---|
3461 | elseif exist(gridname,'file') |
---|
3462 | gridflag='y'; |
---|
3463 | else |
---|
3464 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
3465 | return |
---|
3466 | end |
---|
3467 | end |
---|
3468 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
3469 | threshflag='y'; |
---|
3470 | min_ima=get(handles.MinIma,'String'); |
---|
3471 | max_ima=get(handles.MaxIma,'String'); |
---|
3472 | else |
---|
3473 | threshflag='n'; |
---|
3474 | min_ima='0'; |
---|
3475 | max_ima='4096'; |
---|
3476 | end |
---|
3477 | %main loop |
---|
3478 | filebase=get(handles.displ_filebase,'String'); |
---|
3479 | sizcell=size(filecell); |
---|
3480 | nbfield=sizcell(1); |
---|
3481 | nbslice=sizcell(2); |
---|
3482 | icount=0; |
---|
3483 | for ifile=1:nbfield |
---|
3484 | for j=1:nbslice |
---|
3485 | icount=icount+1; |
---|
3486 | barlength=0.188*icount/(nbfield*nbslice); |
---|
3487 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
3488 | drawnow |
---|
3489 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
3490 | filename_ima([end-3:end])=[];%remove .png extension |
---|
3491 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
3492 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
3493 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
3494 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
3495 | filename_cmx=[filename_cmx 'x']; |
---|
3496 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
3497 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
3498 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
3499 | if isequal(Dt,'0') |
---|
3500 | Dt='1' ;%case of 'displacement' mode |
---|
3501 | end |
---|
3502 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
3503 | else |
---|
3504 | Dt='1'; |
---|
3505 | T0='0'; |
---|
3506 | end |
---|
3507 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
3508 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
3509 | if test_grid && ~isempty(nbslice_grid) |
---|
3510 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
3511 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
3512 | if ~exist(gridname,'file') |
---|
3513 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
3514 | return |
---|
3515 | end |
---|
3516 | end |
---|
3517 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
3518 | if test_mask==0 |
---|
3519 | maskname='noFile use default'; |
---|
3520 | maskflag='n'; |
---|
3521 | else |
---|
3522 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
3523 | maskbase=[filebase '_' maskdispl];% |
---|
3524 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
3525 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
3526 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
3527 | if exist(maskname,'file') |
---|
3528 | maskflag='y'; |
---|
3529 | else |
---|
3530 | maskname='noFile use default'; |
---|
3531 | maskflag='n'; |
---|
3532 | end |
---|
3533 | end |
---|
3534 | textcmx={'############## CMX file';... |
---|
3535 | ['FirstImage ' filename_ima];... |
---|
3536 | ['LastImage ' filename_ima_1];... |
---|
3537 | 'XX' ;... |
---|
3538 | ['Mask ' maskflag] ;... |
---|
3539 | ['MaskName ' maskname];... |
---|
3540 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
3541 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
3542 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
3543 | ['RO ' rho];... |
---|
3544 | ['GridSpacing ' dx ' ' dy];... |
---|
3545 | 'XX 1.0';... |
---|
3546 | ['Dt_TO ' Dt ' ' T0];... |
---|
3547 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
3548 | 'XX 1';... |
---|
3549 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
3550 | ['Grid ' gridflag];... |
---|
3551 | ['GridName ' gridname] ;... |
---|
3552 | 'XX 85';... |
---|
3553 | 'XX 1.0';... |
---|
3554 | 'XX 1.0';... |
---|
3555 | 'Hart 1';... |
---|
3556 | 'DecimalShift 0';... |
---|
3557 | 'Deformation 0';... |
---|
3558 | 'CorrelationMin 0';... |
---|
3559 | 'IntensityMin 0';... |
---|
3560 | ['SeuilImage ' threshflag];... |
---|
3561 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
3562 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
3563 | 'ImageUsedBefore null null'}; |
---|
3564 | textout=char(textcmx); |
---|
3565 | % dlmwrite(filename_cmx,textout,''); |
---|
3566 | fid=fopen([filename_cmx],'w'); |
---|
3567 | fprintf(fid, ['############## CMX file' '\n']); |
---|
3568 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
3569 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
3570 | fprintf(fid, ['XX' '\n' ]); |
---|
3571 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
3572 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
3573 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
3574 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
3575 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
3576 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
3577 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
3578 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
3579 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
3580 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
3581 | fprintf(fid, ['XX 1' '\n' ]); |
---|
3582 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
3583 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
3584 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
3585 | fprintf(fid, ['XX 85' '\n' ]); |
---|
3586 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
3587 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
3588 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
3589 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
3590 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
3591 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
3592 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
3593 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
3594 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
3595 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
3596 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
3597 | fclose(fid); |
---|
3598 | |
---|
3599 | s=-1; |
---|
3600 | display(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog ' &']) |
---|
3601 | eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog ' &']); |
---|
3602 | % if sge%dispatch computation on the cluster using interactive queue |
---|
3603 | % % [s,w] = unix(['qrsh -q fast.q ' civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
3604 | % end |
---|
3605 | % if s~=0 |
---|
3606 | % % ['!' civ1_exe ' -f ' filename_cmx ' > ' namelog] |
---|
3607 | % % eval(['!' civ1_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
3608 | % end |
---|
3609 | end |
---|
3610 | end |
---|
3611 | |
---|
3612 | %------------------------------------------------------------------------ |
---|
3613 | % RUN CIV2 CIV2 CIV2 CIV2 |
---|
3614 | function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
3615 | %------------------------------------------------------------------------ |
---|
3616 | %filecell_2: names of first image |
---|
3617 | %filecell_3: names of second images |
---|
3618 | global civ2_exe sge |
---|
3619 | |
---|
3620 | %names of the civ2 fields |
---|
3621 | field.vel_type='civ2'; |
---|
3622 | field.nb='nb_vectors2'; |
---|
3623 | field.X='vec2_X'; |
---|
3624 | field.Y='vec2_Y'; |
---|
3625 | field.U='vec2_U'; |
---|
3626 | field.V='vec2_V'; |
---|
3627 | |
---|
3628 | %get civ parameters |
---|
3629 | ibx=get(handles.ibx_civ2,'String'); |
---|
3630 | iby=get(handles.iby_civ2,'String'); |
---|
3631 | rho=get(handles.rho_civ2,'String'); |
---|
3632 | decimal=int2str(get(handles.decimal,'Value')); |
---|
3633 | deformation=int2str(get(handles.deformation,'Value')); |
---|
3634 | dx=get(handles.dx_civ2,'String'); |
---|
3635 | dy=get(handles.dy_civ2,'String'); |
---|
3636 | if isequal(str2num(dx),[]) |
---|
3637 | dx='20';%default |
---|
3638 | end |
---|
3639 | if isequal(str2num(dy),[]) |
---|
3640 | dy='20';%default |
---|
3641 | end |
---|
3642 | pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
3643 | pxcmy='1'; |
---|
3644 | A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
3645 | sizim=size(A); |
---|
3646 | npx=num2str(sizim(2)); |
---|
3647 | npy=num2str(sizim(1)); |
---|
3648 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
3649 | filebase=get(handles.displ_filebase,'String'); |
---|
3650 | %grid |
---|
3651 | gridname='';%default ='noFile use default' |
---|
3652 | gridflag='n';%default |
---|
3653 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
3654 | nbslice_grid=[]; |
---|
3655 | if test_grid |
---|
3656 | gridname=get(handles.grid_civ2,'String'); |
---|
3657 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
3658 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
3659 | if ~isempty(nbslice_grid) |
---|
3660 | gridflag='y'; |
---|
3661 | end |
---|
3662 | elseif exist(gridname,'file') |
---|
3663 | gridflag='y'; |
---|
3664 | else |
---|
3665 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
3666 | return |
---|
3667 | end |
---|
3668 | end |
---|
3669 | sizcell=size(filecell_2); |
---|
3670 | nbfield=sizcell(1); |
---|
3671 | nbslice=sizcell(2); |
---|
3672 | |
---|
3673 | %main loop |
---|
3674 | icount=0; |
---|
3675 | for ifile=1:nbfield |
---|
3676 | for j=1:nbslice |
---|
3677 | icount=icount+1; |
---|
3678 | barlength=0.188*icount/(nbfield*nbslice); |
---|
3679 | set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
3680 | drawnow |
---|
3681 | filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
3682 | filename_ima_2([end-3:end])=[];%remove .png extension |
---|
3683 | filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
3684 | filename_ima_3([end-3:end])=[];%remove .png extension |
---|
3685 | filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
3686 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
3687 | filename_cmx=[filename_cmx 'x']; |
---|
3688 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
3689 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
3690 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
3691 | if isequal(Dt,'0') |
---|
3692 | Dt='1' ;%case of 'displacement' mode |
---|
3693 | end |
---|
3694 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
3695 | else |
---|
3696 | Dt='1'; |
---|
3697 | T0='0'; |
---|
3698 | end |
---|
3699 | term_a=num2stra(num_a(j),nom_type_nc); |
---|
3700 | term_b=num2stra(num_b(j),nom_type_nc); |
---|
3701 | filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
3702 | filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
3703 | if test_grid && ~isempty(nbslice_grid) |
---|
3704 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
3705 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
3706 | if ~exist(gridname,'file') |
---|
3707 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
3708 | return |
---|
3709 | end |
---|
3710 | end |
---|
3711 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
3712 | if test_mask==0 |
---|
3713 | maskname='noFile use default'; |
---|
3714 | maskflag='n'; |
---|
3715 | else |
---|
3716 | maskdispl=get(handles.mask_civ2,'String'); |
---|
3717 | maskbase=[filebase '_' maskdispl]; % |
---|
3718 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
3719 | num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
3720 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
3721 | if ~exist(maskname,'file') |
---|
3722 | maskflag='y'; |
---|
3723 | else |
---|
3724 | maskname='noFile use default'; |
---|
3725 | maskflag='n'; |
---|
3726 | end |
---|
3727 | end |
---|
3728 | |
---|
3729 | textcmx={'############## CMX file';... |
---|
3730 | ['FirstImage ' filename_ima_2];... |
---|
3731 | ['LastImage ' filename_ima_3];... |
---|
3732 | 'XX' ;... |
---|
3733 | ['Mask ' maskflag];... |
---|
3734 | ['MaskName ' maskname];... |
---|
3735 | ['ImageSize ' npx ' ' npy];... |
---|
3736 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
3737 | ['SearchBoxeSize ' ibx ' ' iby];... |
---|
3738 | ['RO ' rho];... |
---|
3739 | ['GridSpacing ' dx ' ' dy];... |
---|
3740 | 'XX 1.0';... |
---|
3741 | ['Dt_TO ' Dt ' ' T0];... |
---|
3742 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
3743 | 'XX 1';... |
---|
3744 | ['ShiftXY 0 0'];... |
---|
3745 | ['Grid ' gridflag];... |
---|
3746 | ['GridName ' gridname];... |
---|
3747 | 'XX 85';... |
---|
3748 | 'XX 1.0';... |
---|
3749 | 'XX 1.0';... |
---|
3750 | 'Hart 1';... |
---|
3751 | ['DecimalShift ' decimal];... |
---|
3752 | ['Deformation ' deformation];... |
---|
3753 | 'CorrelationMin 0';... |
---|
3754 | 'IntensityMin 0';... |
---|
3755 | 'SeuilImage n';... |
---|
3756 | 'SeuilImageValues 0 4096';... |
---|
3757 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
3758 | ['ImageUsedBefore ' filename_nc1]}; |
---|
3759 | textout=char(textcmx); |
---|
3760 | dlmwrite(filename_cmx,textout,''); |
---|
3761 | s=-1; |
---|
3762 | display(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog ' &']) |
---|
3763 | eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog ' &']); |
---|
3764 | |
---|
3765 | % if sge%dispatch computation on the cluster using interactive queue |
---|
3766 | % [s,w] = unix(['qrsh -q fast.q ' civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
3767 | % end |
---|
3768 | % if s~=0 |
---|
3769 | % eval(['!' civ2_exe ' -f ' filename_cmx ' > ' namelog]); |
---|
3770 | % ['!' civ2_exe ' -f ' filename_cmx ' > ' namelog] |
---|
3771 | % end |
---|
3772 | end |
---|
3773 | end |
---|
3774 | % close(h) |
---|
3775 | |
---|
3776 | %------------------------------------------------------------------------ |
---|
3777 | % --- PATCH |
---|
3778 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
3779 | %------------------------------------------------------------------------ |
---|
3780 | global patch_exe patch_new_exe |
---|
3781 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
3782 | if test_interp==0 |
---|
3783 | cmd_PATCH=[patch_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
3784 | ' > ' namelog ' 2>&1 &']; % redirect standard output to the log file |
---|
3785 | else %nouveau programme patch |
---|
3786 | cmd_PATCH=[patch_new_exe ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
3787 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1 &']; % redirect standard output to the log file |
---|
3788 | end |
---|
3789 | |
---|
3790 | %------------------------------------------------------------------------ |
---|
3791 | % --- STEREO Interp |
---|
3792 | function cmd=RUN_STINTERP(stinterp_exe,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
3793 | %------------------------------------------------------------------------ |
---|
3794 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
3795 | cmd=[stinterp_exe ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
3796 | ' -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 |
---|
3797 | |
---|
3798 | %------------------------------------------------------------------------ |
---|
3799 | % --- Executes on button press in CIV1. |
---|
3800 | function CIV1_Callback(hObject, eventdata, handles) |
---|
3801 | %------------------------------------------------------------------------ |
---|
3802 | val=get(handles.CIV1,'Value'); |
---|
3803 | if isequal(val,1) |
---|
3804 | enable_civ1(handles,'on') |
---|
3805 | enable_pair1(handles,'on') |
---|
3806 | else |
---|
3807 | enable_civ1(handles,'off') |
---|
3808 | end |
---|
3809 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
3810 | |
---|
3811 | %------------------------------------------------------------------------ |
---|
3812 | % --- Executes on button press in FIX1. |
---|
3813 | function FIX1_Callback(hObject, eventdata, handles) |
---|
3814 | %------------------------------------------------------------------------ |
---|
3815 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
3816 | |
---|
3817 | %------------------------------------------------------------------------ |
---|
3818 | % --- Executes on button press in PATCH1. |
---|
3819 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
3820 | %------------------------------------------------------------------------ |
---|
3821 | if get(handles.PATCH1,'Value')==1 |
---|
3822 | enable_patch1(handles) |
---|
3823 | else |
---|
3824 | desable_patch1(handles) |
---|
3825 | end |
---|
3826 | |
---|
3827 | %------------------------------------------------------------------------ |
---|
3828 | % --- Executes on button press in CIV2. |
---|
3829 | function CIV2_Callback(hObject, eventdata, handles) |
---|
3830 | %------------------------------------------------------------------------ |
---|
3831 | state=get(handles.CIV2,'Value'); |
---|
3832 | enable_civ2(handles,state) |
---|
3833 | if state |
---|
3834 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
3835 | enable_pair1(handles,'on') |
---|
3836 | end |
---|
3837 | |
---|
3838 | %------------------------------------------------------------------------ |
---|
3839 | % --- Executes on button press in FIX2. |
---|
3840 | function FIX2_Callback(hObject, eventdata, handles) |
---|
3841 | %------------------------------------------------------------------------ |
---|
3842 | if get(handles.FIX2,'Value')==1 |
---|
3843 | enable_fix2(handles) |
---|
3844 | if get(handles.CIV2,'Value')==0 |
---|
3845 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
3846 | end |
---|
3847 | else |
---|
3848 | desable_fix2(handles) |
---|
3849 | end |
---|
3850 | |
---|
3851 | %------------------------------------------------------------------------ |
---|
3852 | % --- Executes on button press in PATCH2. |
---|
3853 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
3854 | %------------------------------------------------------------------------ |
---|
3855 | if get(handles.PATCH2,'Value')==1 |
---|
3856 | enable_patch2(handles) |
---|
3857 | if get(handles.CIV2,'Value')==0 |
---|
3858 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
3859 | end |
---|
3860 | else |
---|
3861 | desable_patch2(handles) |
---|
3862 | end |
---|
3863 | |
---|
3864 | %------------------------------------------------------------------------ |
---|
3865 | function first_i_Callback(hObject, eventdata, handles) |
---|
3866 | %------------------------------------------------------------------------ |
---|
3867 | % last_i_Callback(hObject, eventdata, handles) |
---|
3868 | first_i=str2num(get(handles.first_i,'String')); |
---|
3869 | % last_i=str2num(get(handles.last_i,'String')); |
---|
3870 | % ref_i=ceil((first_i+last_i)/2); |
---|
3871 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
3872 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3873 | |
---|
3874 | %------------------------------------------------------------------------ |
---|
3875 | function first_j_Callback(hObject, eventdata, handles) |
---|
3876 | %------------------------------------------------------------------------ |
---|
3877 | first_j=str2num(get(handles.first_j,'String')); |
---|
3878 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
3879 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3880 | |
---|
3881 | %------------------------------------------------------------------------ |
---|
3882 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
3883 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
3884 | %------------------------------------------------------------------------ |
---|
3885 | %determine pair numbers |
---|
3886 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
3887 | index=get(handles.list_pair_civ1,'Value'); |
---|
3888 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
3889 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
3890 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
3891 | pxcmx=pxcm_xy(1); |
---|
3892 | pxcmy=pxcm_xy(2); |
---|
3893 | mode_list=get(handles.mode,'String'); |
---|
3894 | mode_value=get(handles.mode,'Value'); |
---|
3895 | mode=mode_list{mode_value}; |
---|
3896 | if isequal (mode, 'series(Di)' ) |
---|
3897 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
3898 | num1=ref_i-floor(index/2);% first image numbers |
---|
3899 | num2=ref_i+ceil(index/2); |
---|
3900 | num_a=1; |
---|
3901 | num_b=1; |
---|
3902 | elseif isequal (mode, 'series(Dj)') |
---|
3903 | num1=1; |
---|
3904 | num2=1; |
---|
3905 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
3906 | num_a=ref_j-floor(index/2);% first image numbers |
---|
3907 | num_b=ref_j+ceil(index/2); |
---|
3908 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
3909 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
3910 | num1=ref_i; |
---|
3911 | num2=ref_i; |
---|
3912 | num_a=displ_num(1,index); |
---|
3913 | num_b=displ_num(2,index); |
---|
3914 | end |
---|
3915 | dt=time(num2,num_b)-time(num1,num_a); |
---|
3916 | ibx=str2num(get(handles.ibx,'String')); |
---|
3917 | iby=str2num(get(handles.iby,'String')); |
---|
3918 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
3919 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
3920 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
3921 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
3922 | shiftx=round((umin+umax)/2); |
---|
3923 | shifty=round((vmin+vmax)/2); |
---|
3924 | isx=(umax+2-shiftx)*2+ibx; |
---|
3925 | isx=2*ceil(isx/2)+1; |
---|
3926 | isy=(vmax+2-shifty)*2+iby; |
---|
3927 | isy=2*ceil(isy/2)+1; |
---|
3928 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
3929 | set(handles.shifty,'String',num2str(shifty)); |
---|
3930 | set(handles.isx,'String',num2str(isx)); |
---|
3931 | set(handles.isy,'String',num2str(isy)); |
---|
3932 | |
---|
3933 | %------------------------------------------------------------------------ |
---|
3934 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
3935 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
3936 | %------------------------------------------------------------------------ |
---|
3937 | subdir=get(handles.subdir_civ1,'String'); |
---|
3938 | set(handles.subdir_civ2,'String',subdir); |
---|
3939 | if get(handles.CIV1,'Value')==0 |
---|
3940 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
3941 | end |
---|
3942 | |
---|
3943 | %------------------------------------------------------------------------ |
---|
3944 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
3945 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
3946 | %------------------------------------------------------------------------ |
---|
3947 | %update the list of available pairs from netcdf files in the new directory |
---|
3948 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
3949 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
3950 | end |
---|
3951 | |
---|
3952 | %------------------------------------------------------------------------ |
---|
3953 | % --- Executes on button press in get_mask_civ1. |
---|
3954 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
3955 | %------------------------------------------------------------------------ |
---|
3956 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
3957 | if isequal(maskval,0) |
---|
3958 | set(handles.mask_civ1,'String','') |
---|
3959 | else |
---|
3960 | mask_displ='no mask'; %default |
---|
3961 | filebase=get(handles.displ_filebase,'String'); |
---|
3962 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
3963 | if isequal(flag_mask,1) |
---|
3964 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
3965 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3966 | common_path=fileparts(filebase); |
---|
3967 | filebase_a=fullfile(common_path,get(handles.displ_filebase2,'String')); |
---|
3968 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3969 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
3970 | mask_displ='no mask'; |
---|
3971 | end |
---|
3972 | end |
---|
3973 | if isequal(mask_displ,'no mask') |
---|
3974 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3975 | {'*.png', ' (*.png)'; |
---|
3976 | '*.png', '.png files '; ... |
---|
3977 | '*.*', 'All Files (*.*)'}, ... |
---|
3978 | 'Pick a mask file *.png',filebase); |
---|
3979 | mask_displ=fullfile(PathName,FileName); |
---|
3980 | if ~exist(mask_displ,'file') |
---|
3981 | mask_displ='no mask'; |
---|
3982 | end |
---|
3983 | end |
---|
3984 | if isequal(mask_displ,'no mask') |
---|
3985 | set(handles.get_mask_civ1,'Value',0) |
---|
3986 | set(handles.get_mask_fix1,'Value',0) |
---|
3987 | set(handles.get_mask_civ2,'Value',0) |
---|
3988 | set(handles.get_mask_fix2,'Value',0) |
---|
3989 | else |
---|
3990 | set(handles.get_mask_fix1,'Value',1) |
---|
3991 | set(handles.get_mask_fix2,'Value',1) |
---|
3992 | end |
---|
3993 | set(handles.mask_civ1,'String',mask_displ) |
---|
3994 | set(handles.mask_fix1,'String',mask_displ) |
---|
3995 | set(handles.mask_civ2,'String',mask_displ) |
---|
3996 | set(handles.mask_fix2,'String',mask_displ) |
---|
3997 | end |
---|
3998 | |
---|
3999 | %------------------------------------------------------------------------ |
---|
4000 | % --- Executes on button press in get_mask_fix1. |
---|
4001 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
4002 | %------------------------------------------------------------------------ |
---|
4003 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
4004 | if isequal(maskval,0) |
---|
4005 | set(handles.mask_fix1,'String','') |
---|
4006 | else |
---|
4007 | mask_displ='no mask'; %default |
---|
4008 | filebase=get(handles.displ_filebase,'String'); |
---|
4009 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
4010 | if isequal(flag_mask,1) |
---|
4011 | mask_displ=[num2str(nbslice) 'mask']; |
---|
4012 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
4013 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
4014 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
4015 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
4016 | mask_displ='no mask'; |
---|
4017 | end |
---|
4018 | end |
---|
4019 | if isequal(mask_displ,'no mask') |
---|
4020 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4021 | {'*.png', ' (*.png)'; |
---|
4022 | '*.png', '.png files '; ... |
---|
4023 | '*.*', 'All Files (*.*)'}, ... |
---|
4024 | 'Pick a mask file *.png',filebase); |
---|
4025 | mask_displ=fullfile(PathName,FileName); |
---|
4026 | if ~exist(mask_displ,'file') |
---|
4027 | mask_displ='no mask'; |
---|
4028 | end |
---|
4029 | end |
---|
4030 | if isequal(mask_displ,'no mask') |
---|
4031 | set(handles.get_mask_fix1,'Value',0) |
---|
4032 | set(handles.get_mask_civ2,'Value',0) |
---|
4033 | set(handles.get_mask_fix2,'Value',0) |
---|
4034 | else |
---|
4035 | %set(handles.get_mask_civ2,'Value',1) |
---|
4036 | set(handles.get_mask_fix2,'Value',1) |
---|
4037 | end |
---|
4038 | set(handles.mask_fix1,'String',mask_displ) |
---|
4039 | set(handles.mask_civ2,'String',mask_displ) |
---|
4040 | set(handles.mask_fix2,'String',mask_displ) |
---|
4041 | end |
---|
4042 | |
---|
4043 | %------------------------------------------------------------------------ |
---|
4044 | % --- Executes on button press in get_mask_civ2. |
---|
4045 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
4046 | %------------------------------------------------------------------------ |
---|
4047 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
4048 | if isequal(maskval,0) |
---|
4049 | set(handles.mask_civ2,'String','') |
---|
4050 | else |
---|
4051 | mask_displ='no mask'; %default |
---|
4052 | filebase=get(handles.displ_filebase,'String'); |
---|
4053 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
4054 | if isequal(flag_mask,1) |
---|
4055 | mask_displ=[num2str(nbslice) 'mask']; |
---|
4056 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
4057 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
4058 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
4059 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
4060 | mask_displ='no mask'; |
---|
4061 | end |
---|
4062 | end |
---|
4063 | if isequal(mask_displ,'no mask') |
---|
4064 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4065 | {'*.png', ' (*.png)'; |
---|
4066 | '*.png', '.png files '; ... |
---|
4067 | '*.*', 'All Files (*.*)'}, ... |
---|
4068 | 'Pick a mask file *.png',filebase); |
---|
4069 | mask_displ=fullfile(PathName,FileName); |
---|
4070 | if ~exist(mask_displ,'file') |
---|
4071 | mask_displ='no mask'; |
---|
4072 | end |
---|
4073 | end |
---|
4074 | if isequal(mask_displ,'no mask') |
---|
4075 | set(handles.get_mask_civ2,'Value',0) |
---|
4076 | set(handles.get_mask_fix2,'Value',0) |
---|
4077 | else |
---|
4078 | set(handles.get_mask_fix2,'Value',1) |
---|
4079 | end |
---|
4080 | set(handles.mask_civ2,'String',mask_displ) |
---|
4081 | set(handles.mask_fix2,'String',mask_displ) |
---|
4082 | end |
---|
4083 | |
---|
4084 | %------------------------------------------------------------------------ |
---|
4085 | % --- Executes on button press in get_mask_fix2. |
---|
4086 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
4087 | %------------------------------------------------------------------------ |
---|
4088 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
4089 | if isequal(maskval,0) |
---|
4090 | set(handles.mask_fix2,'String','') |
---|
4091 | else |
---|
4092 | mask_displ='no mask'; %default |
---|
4093 | filebase=get(handles.displ_filebase,'String'); |
---|
4094 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
4095 | if isequal(flag_mask,1) |
---|
4096 | mask_displ=[num2str(nbslice) 'mask']; |
---|
4097 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
4098 | filebase_a=get(handles.displ_filebase2,'String'); |
---|
4099 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
4100 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
4101 | mask_displ='no mask'; |
---|
4102 | end |
---|
4103 | end |
---|
4104 | if isequal(mask_displ,'no mask') |
---|
4105 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4106 | {'*.png', ' (*.png)'; |
---|
4107 | '*.png', '.png files '; ... |
---|
4108 | '*.*', 'All Files (*.*)'}, ... |
---|
4109 | 'Pick a mask file *.png',filebase); |
---|
4110 | mask_displ=fullfile(PathName,FileName); |
---|
4111 | if ~exist(mask_displ,'file') |
---|
4112 | mask_displ='no mask'; |
---|
4113 | end |
---|
4114 | end |
---|
4115 | if isequal(mask_displ,'no mask') |
---|
4116 | set(handles.get_mask_fix2,'Value',0) |
---|
4117 | end |
---|
4118 | set(handles.mask_fix2,'String',mask_displ) |
---|
4119 | end |
---|
4120 | |
---|
4121 | %------------------------------------------------------------------------ |
---|
4122 | % --- function called to look for mask files |
---|
4123 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
4124 | %------------------------------------------------------------------------ |
---|
4125 | %detect mask files, images with appropriate file base |
---|
4126 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
4127 | %flag_mask=1 indicates detection |
---|
4128 | |
---|
4129 | flag_mask=0;%default |
---|
4130 | nbslice=1; |
---|
4131 | |
---|
4132 | % subdir=get(handles.subdir_civ1,'String'); |
---|
4133 | [Path,Name]=fileparts(filebase); |
---|
4134 | if ~isdir(Path) |
---|
4135 | msgbox_uvmat('ERROR','no path for input files') |
---|
4136 | return |
---|
4137 | end |
---|
4138 | currentdir=pwd; |
---|
4139 | cd(Path);%move in the dir of the root name filebase |
---|
4140 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
4141 | cd(currentdir);%come back to the current working directory |
---|
4142 | if ~isempty(maskfiles) |
---|
4143 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
4144 | % else |
---|
4145 | flag_mask=1; |
---|
4146 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
4147 | [Path2,Name,ext]=fileparts(maskname); |
---|
4148 | Namedouble=double(Name); |
---|
4149 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
4150 | ind_mask=findstr('mask',Name); |
---|
4151 | i=ind_mask-1; |
---|
4152 | while val(i)==0 & i>0 |
---|
4153 | i=i-1; |
---|
4154 | end |
---|
4155 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
4156 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
4157 | flag_mask=1; |
---|
4158 | else |
---|
4159 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
4160 | return |
---|
4161 | nbslice=1; |
---|
4162 | end |
---|
4163 | end |
---|
4164 | |
---|
4165 | %------------------------------------------------------------------------ |
---|
4166 | % --- function called to look for grid files |
---|
4167 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
4168 | %------------------------------------------------------------------------ |
---|
4169 | flag_mask=0;%default |
---|
4170 | nbslice=1; |
---|
4171 | [Path,Name]=fileparts(filebase); |
---|
4172 | currentdir=pwd; |
---|
4173 | cd(Path);%move in the dir of the root name filebase |
---|
4174 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
4175 | cd(currentdir);%come back to the current working directory |
---|
4176 | if ~isempty(maskfiles) |
---|
4177 | flag_mask=1; |
---|
4178 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
4179 | [Path2,Name,ext]=fileparts(maskname); |
---|
4180 | Namedouble=double(Name); |
---|
4181 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
4182 | ind_mask=findstr('grid',Name); |
---|
4183 | i=ind_mask-1; |
---|
4184 | while val(i)==0 & i>0 |
---|
4185 | i=i-1; |
---|
4186 | end |
---|
4187 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
4188 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
4189 | flag_mask=1; |
---|
4190 | else |
---|
4191 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
4192 | return |
---|
4193 | nbslice=1; |
---|
4194 | end |
---|
4195 | end |
---|
4196 | |
---|
4197 | %------------------------------------------------------------------------ |
---|
4198 | % --- transform numbers to letters |
---|
4199 | function str=num2stra(num,nom_type); |
---|
4200 | %------------------------------------------------------------------------ |
---|
4201 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
4202 | str=char(96+num); |
---|
4203 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
4204 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
4205 | str=''; |
---|
4206 | else |
---|
4207 | str=num2str(num); |
---|
4208 | end |
---|
4209 | |
---|
4210 | %------------------------------------------------------------------------ |
---|
4211 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
4212 | %------------------------------------------------------------------------ |
---|
4213 | set(handles.mask_civ1,'UserData',[]) |
---|
4214 | set(handles.mask_civ1,'String','') |
---|
4215 | |
---|
4216 | %------------------------------------------------------------------------ |
---|
4217 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
4218 | %------------------------------------------------------------------------ |
---|
4219 | set(handles.mask_civ2,'UserData',[]) |
---|
4220 | set(handles.mask_civ2,'String','') |
---|
4221 | |
---|
4222 | %------------------------------------------------------------------------ |
---|
4223 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
4224 | %------------------------------------------------------------------------ |
---|
4225 | set(handles.mask_fix1,'UserData',[]) |
---|
4226 | set(handles.mask_fix1,'String','') |
---|
4227 | |
---|
4228 | %------------------------------------------------------------------------ |
---|
4229 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
4230 | %------------------------------------------------------------------------ |
---|
4231 | set(handles.mask_fix2,'UserData',[]) |
---|
4232 | set(handles.mask_fix2,'String','') |
---|
4233 | |
---|
4234 | %------------------------------------------------------------------------ |
---|
4235 | % --- Executes on button press in list_subdir_civ1. |
---|
4236 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
4237 | %------------------------------------------------------------------------ |
---|
4238 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
4239 | val=get(handles.list_subdir_civ1,'Value'); |
---|
4240 | if val>1 |
---|
4241 | subdir=list_subdir_civ1{val}; |
---|
4242 | set(handles.subdir_civ1,'String',subdir); |
---|
4243 | set(handles.list_subdir_civ1,'Value',1); |
---|
4244 | end |
---|
4245 | |
---|
4246 | %------------------------------------------------------------------------ |
---|
4247 | % --- Executes on button press in list_subdir_civ2. |
---|
4248 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
4249 | %------------------------------------------------------------------------ |
---|
4250 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
4251 | val=get(handles.list_subdir_civ2,'Value'); |
---|
4252 | if val>1 |
---|
4253 | subdir=list_subdir_civ2{val}; |
---|
4254 | set(handles.subdir_civ2,'String',subdir); |
---|
4255 | set(handles.list_subdir_civ2,'Value',1); |
---|
4256 | end |
---|
4257 | |
---|
4258 | %------------------------------------------------------------------------ |
---|
4259 | % --- Executes on button press in browse_gridciv1. |
---|
4260 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
4261 | %------------------------------------------------------------------------ |
---|
4262 | value=get(handles.browse_gridciv1,'Value'); |
---|
4263 | testgrid=0; |
---|
4264 | if value |
---|
4265 | filebase=get(handles.displ_filebase,'String'); |
---|
4266 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
4267 | if isequal(flag_grid,1) |
---|
4268 | filegrid=[num2str(nbslice) 'grid']; |
---|
4269 | testgrid=1; |
---|
4270 | else |
---|
4271 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4272 | {'*.grid', ' (*.grid)'; |
---|
4273 | '*.grid', '.grid files '; ... |
---|
4274 | '*.*', 'All Files (*.*)'}, ... |
---|
4275 | 'Pick a file',filebase); |
---|
4276 | filegrid=fullfile(PathName,FileName); |
---|
4277 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
4278 | testgrid=1; |
---|
4279 | end |
---|
4280 | end |
---|
4281 | end |
---|
4282 | if testgrid |
---|
4283 | set(handles.browse_gridciv2,'Value',1) |
---|
4284 | set(handles.get_gridpatch1,'Value',1) |
---|
4285 | set(handles.get_gridpatch2,'Value',1) |
---|
4286 | set(handles.dx_civ1,'Visible','off'); |
---|
4287 | set(handles.dy_civ1,'Visible','off'); |
---|
4288 | set(handles.dx_civ2,'Visible','off'); |
---|
4289 | set(handles.dy_civ2,'Visible','off'); |
---|
4290 | set(handles.grid_civ1,'String',filegrid) |
---|
4291 | set(handles.grid_patch1,'String',filegrid) |
---|
4292 | set(handles.grid_civ2,'String',filegrid) |
---|
4293 | set(handles.grid_patch2,'String',filegrid) |
---|
4294 | else |
---|
4295 | set(handles.browse_gridciv1,'Value',0); |
---|
4296 | set(handles.browse_gridciv2,'Value',0); |
---|
4297 | set(handles.get_gridpatch1,'Value',0) |
---|
4298 | set(handles.get_gridpatch2,'Value',0) |
---|
4299 | set(handles.dx_civ1,'Visible','on'); |
---|
4300 | set(handles.dy_civ1,'Visible','on'); |
---|
4301 | set(handles.dx_civ2,'Visible','on'); |
---|
4302 | set(handles.dy_civ2,'Visible','on'); |
---|
4303 | set(handles.grid_civ1,'String','') |
---|
4304 | set(handles.grid_patch1,'String','') |
---|
4305 | set(handles.grid_civ2,'String','') |
---|
4306 | set(handles.grid_patch2,'String','') |
---|
4307 | end |
---|
4308 | |
---|
4309 | %------------------------------------------------------------------------ |
---|
4310 | % --- Executes on button press in browse_gridciv1. |
---|
4311 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
4312 | %------------------------------------------------------------------------ |
---|
4313 | value=get(handles.browse_gridciv2,'Value'); |
---|
4314 | if value |
---|
4315 | filebase=get(handles.displ_filebase,'String'); |
---|
4316 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
4317 | if isequal(flag_grid,1) |
---|
4318 | mask_displ=[num2str(nbslice) 'grid']; |
---|
4319 | set(handles.grid_civ2,'String',mask_displ) |
---|
4320 | set(handles.dx_civ2,'Visible','off'); |
---|
4321 | set(handles.dy_civ2,'Visible','off'); |
---|
4322 | else |
---|
4323 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4324 | {'*.grid', ' (*.grid)'; |
---|
4325 | '*.grid', '.grid files '; ... |
---|
4326 | '*.*', 'All Files (*.*)'}, ... |
---|
4327 | 'Pick a file',filebase); |
---|
4328 | filegrid=fullfile(PathName,FileName); |
---|
4329 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
4330 | set(handles.browse_gridciv2,'Value',0); |
---|
4331 | set(handles.grid_civ2,'string',''); |
---|
4332 | set(handles.dx_civ2,'Visible','on'); |
---|
4333 | set(handles.dy_civ2,'Visible','on'); |
---|
4334 | set(handles.grid_civ2,'string',''); |
---|
4335 | else |
---|
4336 | set(handles.grid_civ2,'string',filegrid); |
---|
4337 | set(handles.dx_civ2,'Visible','off'); |
---|
4338 | set(handles.dy_civ2,'Visible','off'); |
---|
4339 | set(handles.grid_civ2,'string',filegrid); |
---|
4340 | end |
---|
4341 | end |
---|
4342 | else |
---|
4343 | set(handles.grid_civ2,'string',''); |
---|
4344 | set(handles.dx_civ2,'Visible','on'); |
---|
4345 | set(handles.dy_civ2,'Visible','on'); |
---|
4346 | set(handles.grid_civ2,'string',''); |
---|
4347 | end |
---|
4348 | |
---|
4349 | % % --- Executes on button press in browse_gridciv2. |
---|
4350 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
4351 | % |
---|
4352 | % filebase=get(handles.displ_filebase,'String'); |
---|
4353 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
4354 | % {'*.grid', ' (*.grid)'; |
---|
4355 | % '*.grid', '.grid files '; ... |
---|
4356 | % '*.*', 'All Files (*.*)'}, ... |
---|
4357 | % 'Pick a file',filebase); |
---|
4358 | % filegrid=fullfile(PathName,FileName); |
---|
4359 | % set(handles.grid_civ2,'string',filegrid); |
---|
4360 | % set(handles.dx_civ2,'String',' '); |
---|
4361 | % set(handles.dy_civ2,'String',' '); |
---|
4362 | % % set(handles.grid_patch2,'string',filegrid); |
---|
4363 | |
---|
4364 | % --- Executes on button press in get_gridpatch1. |
---|
4365 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
4366 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
4367 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
4368 | % handles structure with handles and user data (see GUIDATA) |
---|
4369 | |
---|
4370 | filebase=get(handles.displ_filebase,'String'); |
---|
4371 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4372 | {'*.grid', ' (*.grid)'; |
---|
4373 | '*.grid', '.grid files '; ... |
---|
4374 | '*.*', 'All Files (*.*)'}, ... |
---|
4375 | 'Pick a file',filebase); |
---|
4376 | filegrid=fullfile(PathName,FileName); |
---|
4377 | set(handles.grid_patch1,'string',filegrid); |
---|
4378 | % set(handles.grid_patch2,'string',filegrid |
---|
4379 | |
---|
4380 | %------------------------------------------------------------------------ |
---|
4381 | % --- Executes on button press in get_gridpatch2. |
---|
4382 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
4383 | %------------------------------------------------------------------------ |
---|
4384 | |
---|
4385 | %------------------------------------------------------------------------ |
---|
4386 | function enable_civ1(handles,state) |
---|
4387 | %------------------------------------------------------------------------ |
---|
4388 | if isequal(state,0) |
---|
4389 | state='off'; |
---|
4390 | end |
---|
4391 | if isequal(state,1) |
---|
4392 | state='on'; |
---|
4393 | end |
---|
4394 | if isequal(state,'on') |
---|
4395 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
4396 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
4397 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
4398 | else |
---|
4399 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4400 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4401 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4402 | end |
---|
4403 | set(handles.ibx,'Visible',state) |
---|
4404 | set(handles.iby,'Visible',state) |
---|
4405 | set(handles.isx,'Visible',state) |
---|
4406 | set(handles.isy,'Visible',state) |
---|
4407 | set(handles.shiftx,'Visible',state) |
---|
4408 | set(handles.shifty,'Visible',state) |
---|
4409 | set(handles.rho,'Visible',state) |
---|
4410 | set(handles.dx_civ1,'Visible',state) |
---|
4411 | set(handles.dy_civ1,'Visible',state) |
---|
4412 | set(handles.calcul_search,'Visible',state) |
---|
4413 | set(handles.u_text,'Visible',state) |
---|
4414 | set(handles.v_text,'Visible',state) |
---|
4415 | set(handles.min,'Visible',state) |
---|
4416 | set(handles.max,'Visible',state) |
---|
4417 | set(handles.umin,'Visible',state) |
---|
4418 | set(handles.umax,'Visible',state) |
---|
4419 | set(handles.vmin,'Visible',state) |
---|
4420 | set(handles.vmax,'Visible',state) |
---|
4421 | set(handles.grid_civ1,'Visible',state) |
---|
4422 | set(handles.mask_civ1,'Visible',state) |
---|
4423 | set(handles.browse_gridciv1,'Visible',state) |
---|
4424 | set(handles.get_mask_civ1,'Visible',state) |
---|
4425 | set(handles.parameters,'Visible',state) |
---|
4426 | set(handles.grid,'Visible',state) |
---|
4427 | set(handles.dx_civ1,'Visible',state) |
---|
4428 | set(handles.dy_civ1,'Visible',state) |
---|
4429 | set(handles.ImaThreshold,'Visible',state) |
---|
4430 | if isequal(state,'off') |
---|
4431 | set(handles.MinIma,'Visible','off') |
---|
4432 | set(handles.MaxIma,'Visible','off') |
---|
4433 | set(handles.ImaThreshold,'Value',0) |
---|
4434 | end |
---|
4435 | set(handles.dx_civ1_title,'Visible',state) |
---|
4436 | set(handles.dy_civ1_title,'Visible',state) |
---|
4437 | set(handles.ImaThreshold_title,'Visible',state) |
---|
4438 | set(handles.ib_title,'Visible',state) |
---|
4439 | set(handles.is_title,'Visible',state) |
---|
4440 | set(handles.shift_title,'Visible',state) |
---|
4441 | set(handles.rho_title,'Visible',state) |
---|
4442 | |
---|
4443 | %------------------------------------------------------------------------ |
---|
4444 | function enable_fix1(handles,state) |
---|
4445 | %------------------------------------------------------------------------ |
---|
4446 | if isequal(state,0) |
---|
4447 | state='off'; |
---|
4448 | end |
---|
4449 | if isequal(state,1) |
---|
4450 | state='on'; |
---|
4451 | end |
---|
4452 | if isequal(state,'on') |
---|
4453 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
4454 | else |
---|
4455 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4456 | end |
---|
4457 | set(handles.REMOVE,'Visible',state) |
---|
4458 | set(handles.vec_Fmin2,'Visible',state) |
---|
4459 | set(handles.vec_F2,'Visible',state) |
---|
4460 | set(handles.vec_F3,'Visible',state) |
---|
4461 | set(handles.thresh_vecC,'Visible',state) |
---|
4462 | set(handles.thresh_vecC_title,'Visible',state) |
---|
4463 | set(handles.thresh_vel,'Visible',state) |
---|
4464 | set(handles.thresh_vel_text,'Visible',state) |
---|
4465 | set(handles.mask_fix1,'Visible',state) |
---|
4466 | set(handles.get_mask_fix1,'Visible',state) |
---|
4467 | set(handles.get_ref_fix1,'Visible',state) |
---|
4468 | set(handles.ref_fix1,'Visible',state) |
---|
4469 | set(handles.inf_sup1,'Visible',state) |
---|
4470 | set(handles.field_ref1,'Visible',state) |
---|
4471 | |
---|
4472 | %------------------------------------------------------------------------ |
---|
4473 | function enable_patch1(handles) |
---|
4474 | %------------------------------------------------------------------------ |
---|
4475 | global patch_new_exe |
---|
4476 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
4477 | set(handles.rho_patch1,'Visible','on') |
---|
4478 | set(handles.rho_text1,'Visible','on') |
---|
4479 | set(handles.thresh_patch1,'Visible','on') |
---|
4480 | set(handles.thresh_text1,'Visible','on') |
---|
4481 | set(handles.subdomain_patch1,'Visible','on') |
---|
4482 | set(handles.subdomain_text1,'Visible','on') |
---|
4483 | set(handles.nx_patch1,'Visible','on') |
---|
4484 | set(handles.ny_patch1,'Visible','on') |
---|
4485 | set(handles.nx_patch1_title,'Visible','on') |
---|
4486 | set(handles.ny_patch1_title,'Visible','on') |
---|
4487 | if (~isequal(patch_new_exe,[]) & ~isequal(patch_new_exe,[])) |
---|
4488 | set(handles.test_interp,'Visible','on'); |
---|
4489 | end |
---|
4490 | set(handles.get_gridpatch1,'Visible','on') |
---|
4491 | set(handles.grid_patch1,'string','none'); |
---|
4492 | set(handles.grid_patch1,'Visible','on') |
---|
4493 | |
---|
4494 | %------------------------------------------------------------------------ |
---|
4495 | function desable_patch1(handles) |
---|
4496 | %------------------------------------------------------------------------ |
---|
4497 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4498 | set(handles.rho_patch1,'Visible','off') |
---|
4499 | set(handles.rho_text1,'Visible','off') |
---|
4500 | set(handles.thresh_patch1,'Visible','off') |
---|
4501 | set(handles.thresh_text1,'Visible','off') |
---|
4502 | set(handles.subdomain_patch1,'Visible','off') |
---|
4503 | set(handles.subdomain_text1,'Visible','off') |
---|
4504 | set(handles.nx_patch1,'Visible','off') |
---|
4505 | set(handles.ny_patch1,'Visible','off') |
---|
4506 | set(handles.nx_patch1_title,'Visible','off') |
---|
4507 | set(handles.ny_patch1_title,'Visible','off') |
---|
4508 | set(handles.test_interp,'Visible','off') |
---|
4509 | set(handles.get_gridpatch1,'Visible','off') |
---|
4510 | set(handles.grid_patch1,'Visible','off') |
---|
4511 | |
---|
4512 | %------------------------------------------------------------------------ |
---|
4513 | function enable_civ2(handles,state) |
---|
4514 | %------------------------------------------------------------------------ |
---|
4515 | if isequal(state,0) |
---|
4516 | state='off'; |
---|
4517 | end |
---|
4518 | if isequal(state,1) |
---|
4519 | state='on'; |
---|
4520 | end |
---|
4521 | if isequal(state,'on') |
---|
4522 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
4523 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
4524 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
4525 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
4526 | else |
---|
4527 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4528 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4529 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4530 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4531 | end |
---|
4532 | set(handles.ibx_civ2,'Visible',state) |
---|
4533 | set(handles.iby_civ2,'Visible',state) |
---|
4534 | set(handles.decimal,'Visible',state) |
---|
4535 | set(handles.deformation,'Visible',state) |
---|
4536 | set(handles.rho_civ2,'Visible',state) |
---|
4537 | set(handles.dx_civ2,'Visible',state) |
---|
4538 | set(handles.dy_civ2,'Visible',state) |
---|
4539 | set(handles.browse_gridciv2,'Visible',state) |
---|
4540 | set(handles.get_mask_civ2,'Visible',state) |
---|
4541 | set(handles.parameters,'Visible',state) |
---|
4542 | set(handles.grid,'Visible',state) |
---|
4543 | set(handles.parameters_text,'Visible',state) |
---|
4544 | set(handles.grid_text,'Visible',state) |
---|
4545 | set(handles.grid_civ2,'Visible',state) |
---|
4546 | set(handles.mask_civ2,'Visible',state) |
---|
4547 | set(handles.dx_civ2_title,'Visible',state) |
---|
4548 | set(handles.dy_civ2_title,'Visible',state) |
---|
4549 | set(handles.ibx_civ2_text,'Visible',state) |
---|
4550 | set(handles.rho_civ2_title,'Visible',state) |
---|
4551 | set(handles.ImaThreshold2,'Visible',state) |
---|
4552 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
4553 | if isequal(state,'off') |
---|
4554 | set(handles.MinIma2,'Visible','off') |
---|
4555 | set(handles.MaxIma2,'Visible','off') |
---|
4556 | set(handles.ImaThreshold2,'Value',0) |
---|
4557 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
4558 | set(handles.list_pair_civ2,'Visible','off') |
---|
4559 | set(handles.subdir_civ2,'Visible','off') |
---|
4560 | set(handles.subdir_civ2_text,'Visible','off') |
---|
4561 | end |
---|
4562 | else |
---|
4563 | set(handles.list_pair_civ2,'Visible','on') |
---|
4564 | set(handles.subdir_civ2,'Visible','on') |
---|
4565 | set(handles.subdir_civ2_text,'Visible','on') |
---|
4566 | end |
---|
4567 | |
---|
4568 | %------------------------------------------------------------------------ |
---|
4569 | function enable_fix2(handles) |
---|
4570 | %------------------------------------------------------------------------ |
---|
4571 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
4572 | set(handles.REMOVE2,'Visible','on') |
---|
4573 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
4574 | set(handles.vec_F4,'Visible','on') |
---|
4575 | set(handles.vec_F3_2,'Visible','on') |
---|
4576 | set(handles.thresh_vec2C,'Visible','on') |
---|
4577 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
4578 | set(handles.thresh_vel2,'Visible','on') |
---|
4579 | set(handles.thresh_vel2_text,'Visible','on') |
---|
4580 | set(handles.mask_fix2,'Visible','on') |
---|
4581 | set(handles.get_mask_fix2,'Visible','on') |
---|
4582 | set(handles.list_pair_civ2,'Visible','on') |
---|
4583 | set(handles.subdir_civ2,'Visible','on') |
---|
4584 | set(handles.subdir_civ2_text,'Visible','on') |
---|
4585 | set(handles.get_ref_fix2,'Visible','on') |
---|
4586 | set(handles.ref_fix2,'Visible','on') |
---|
4587 | set(handles.inf_sup2,'Visible','on') |
---|
4588 | set(handles.field_ref2,'Visible','on') |
---|
4589 | |
---|
4590 | %------------------------------------------------------------------------ |
---|
4591 | function desable_fix2(handles) |
---|
4592 | %------------------------------------------------------------------------ |
---|
4593 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4594 | set(handles.REMOVE2,'Visible','off') |
---|
4595 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
4596 | set(handles.vec_F4,'Visible','off') |
---|
4597 | set(handles.vec_F3_2,'Visible','off') |
---|
4598 | set(handles.thresh_vec2C,'Visible','off') |
---|
4599 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
4600 | set(handles.thresh_vel2,'Visible','off') |
---|
4601 | set(handles.thresh_vel2_text,'Visible','off') |
---|
4602 | set(handles.mask_fix2,'Visible','off') |
---|
4603 | set(handles.get_mask_fix2,'Visible','off') |
---|
4604 | set(handles.get_ref_fix2,'Visible','off') |
---|
4605 | set(handles.ref_fix2,'Visible','off') |
---|
4606 | set(handles.inf_sup2,'Visible','off') |
---|
4607 | set(handles.field_ref2,'Visible','off') |
---|
4608 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
4609 | set(handles.list_pair_civ2,'Visible','off') |
---|
4610 | set(handles.subdir_civ2,'Visible','off') |
---|
4611 | set(handles.subdir_civ2_text,'Visible','off') |
---|
4612 | end |
---|
4613 | |
---|
4614 | %------------------------------------------------------------------------ |
---|
4615 | function enable_patch2(handles) |
---|
4616 | %------------------------------------------------------------------------ |
---|
4617 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
4618 | %set(handles.rho_patch2,'Visible','on') |
---|
4619 | set(handles.rho_text2,'Visible','on') |
---|
4620 | set(handles.thresh_patch2,'Visible','on') |
---|
4621 | set(handles.thresh_text2,'Visible','on') |
---|
4622 | set(handles.subdomain_patch2,'Visible','on') |
---|
4623 | set(handles.subdomain_text2,'Visible','on') |
---|
4624 | set(handles.nx_patch2,'Visible','on') |
---|
4625 | set(handles.ny_patch2,'Visible','on') |
---|
4626 | set(handles.nx_patch2_title,'Visible','on') |
---|
4627 | set(handles.ny_patch2_title,'Visible','on') |
---|
4628 | set(handles.get_gridpatch2,'Visible','on') |
---|
4629 | set(handles.grid_patch2,'Visible','on') |
---|
4630 | set(handles.list_pair_civ2,'Visible','on') |
---|
4631 | set(handles.subdir_civ2,'Visible','on') |
---|
4632 | set(handles.subdir_civ2_text,'Visible','on') |
---|
4633 | |
---|
4634 | %------------------------------------------------------------------------ |
---|
4635 | function desable_patch2(handles) |
---|
4636 | %------------------------------------------------------------------------ |
---|
4637 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4638 | set(handles.rho_patch2,'Visible','off') |
---|
4639 | set(handles.rho_text2,'Visible','off') |
---|
4640 | set(handles.thresh_patch2,'Visible','off') |
---|
4641 | set(handles.thresh_text2,'Visible','off') |
---|
4642 | set(handles.subdomain_patch2,'Visible','off') |
---|
4643 | set(handles.subdomain_text2,'Visible','off') |
---|
4644 | set(handles.nx_patch2,'Visible','off') |
---|
4645 | set(handles.ny_patch2,'Visible','off') |
---|
4646 | set(handles.nx_patch2_title,'Visible','off') |
---|
4647 | set(handles.ny_patch2_title,'Visible','off') |
---|
4648 | set(handles.get_gridpatch2,'Visible','off') |
---|
4649 | set(handles.grid_patch2,'Visible','off') |
---|
4650 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
4651 | set(handles.list_pair_civ2,'Visible','off') |
---|
4652 | set(handles.subdir_civ2,'Visible','off') |
---|
4653 | set(handles.subdir_civ2_text,'Visible','off') |
---|
4654 | end |
---|
4655 | |
---|
4656 | %------------------------------------------------------------------------ |
---|
4657 | function enable_pair1(handles,state) |
---|
4658 | %------------------------------------------------------------------------ |
---|
4659 | set(handles.subdir_civ1,'Visible',state) |
---|
4660 | set(handles.list_subdir_civ1,'Visible',state) |
---|
4661 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
4662 | set(handles.frame_subdirciv1,'Visible',state) |
---|
4663 | set(handles.list_pair_civ1,'Visible',state) |
---|
4664 | set(handles.PAIR_txt,'Visible',state) |
---|
4665 | %set(handles.dt_display_txt,'Visible',state) |
---|
4666 | set(handles.dt_unit,'Visible',state) |
---|
4667 | set(handles.PAIR_frame,'Visible',state) |
---|
4668 | |
---|
4669 | %------------------------------------------------------------------------ |
---|
4670 | % --- Read the parameters for civ1 on the interface |
---|
4671 | function par=read_param_civ1(handles,file_ima) |
---|
4672 | %------------------------------------------------------------------------ |
---|
4673 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
4674 | par.ibx=num2str(ibx_val); |
---|
4675 | iby_val=str2num(get(handles.iby,'String')); |
---|
4676 | par.iby=num2str(iby_val); |
---|
4677 | isx=get(handles.isx,'String'); |
---|
4678 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
4679 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
4680 | isy=get(handles.isy,'String'); |
---|
4681 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
4682 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
4683 | par.isx=get(handles.isx,'String'); |
---|
4684 | par.isy=get(handles.isy,'String'); |
---|
4685 | par.shiftx=get(handles.shiftx,'String'); |
---|
4686 | par.shifty=get(handles.shifty,'String'); |
---|
4687 | if isempty(str2num(par.isx)) |
---|
4688 | par.isx='41';%default |
---|
4689 | set(handles.isx,'String','41'); |
---|
4690 | end |
---|
4691 | if isempty(str2num(par.isy)) |
---|
4692 | par.isy='41'; %default |
---|
4693 | set(handles.isy,'String','41'); |
---|
4694 | end |
---|
4695 | if isempty(str2num(par.shiftx)) |
---|
4696 | par.shiftx='0';%default |
---|
4697 | set(handles.shiftx,'String','0'); |
---|
4698 | end |
---|
4699 | if isempty(str2num(par.shifty)) |
---|
4700 | par.shifty='0'; %default |
---|
4701 | set(handles.shifty,'String','0'); |
---|
4702 | end |
---|
4703 | par.rho=get(handles.rho,'String'); |
---|
4704 | par.dx=get(handles.dx_civ1,'String'); |
---|
4705 | par.dy=get(handles.dy_civ1,'String'); |
---|
4706 | if isequal(str2num(par.dx),[]) |
---|
4707 | if isempty(get(handles.grid_civ1,'String')); |
---|
4708 | par.dx='0'; %just read by civ program, not used |
---|
4709 | else |
---|
4710 | par.dx='20';%default |
---|
4711 | set(handles.dx_civ1,'String','20'); |
---|
4712 | end |
---|
4713 | end |
---|
4714 | if isequal(str2num(par.dy),[]) |
---|
4715 | if isempty(get(handles.grid_civ1,'String')); |
---|
4716 | par.dy='0';%just read by civ program, not used |
---|
4717 | else |
---|
4718 | par.dy='20';%default |
---|
4719 | set(handles.dy_civ1_title,'String','20'); |
---|
4720 | end |
---|
4721 | end |
---|
4722 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
4723 | par.pxcmy='1'; |
---|
4724 | % end |
---|
4725 | A=imread(file_ima);%read the first image to get the size |
---|
4726 | sizim=size(A); |
---|
4727 | par.npx=num2str(sizim(2)); |
---|
4728 | par.npy=num2str(sizim(1)); |
---|
4729 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
4730 | par.gridname=get(handles.grid_civ1,'String'); |
---|
4731 | par.gridflag='y'; |
---|
4732 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
4733 | par.gridname='nogrid'; |
---|
4734 | par.gridflag='n'; |
---|
4735 | end |
---|
4736 | |
---|
4737 | %------------------------------------------------------------------------ |
---|
4738 | function par=read_param_civ2(handles,file_ima) |
---|
4739 | %------------------------------------------------------------------------ |
---|
4740 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
4741 | par.iby=get(handles.iby_civ2,'String'); |
---|
4742 | par.rho=get(handles.rho_civ2,'String'); |
---|
4743 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
4744 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
4745 | par.dx=get(handles.dx_civ2,'String'); |
---|
4746 | par.dy=get(handles.dy_civ2,'String'); |
---|
4747 | if isequal(str2num(par.dx),[]) |
---|
4748 | if isempty(get(handles.grid_civ2,'String')); |
---|
4749 | par.dx='0'; %just read by civ program, not used |
---|
4750 | else |
---|
4751 | par.dx='20';%default |
---|
4752 | set(handles.dx_civ2,'String','20'); |
---|
4753 | end |
---|
4754 | end |
---|
4755 | if isequal(str2num(par.dy),[]) |
---|
4756 | if isempty(get(handles.grid_civ2,'String')); |
---|
4757 | par.dy='0';%just read by civ program, not used |
---|
4758 | else |
---|
4759 | par.dy='20';%default |
---|
4760 | set(handles.dy_civ2,'String','20'); |
---|
4761 | end |
---|
4762 | end |
---|
4763 | par.pxcmx='1'; |
---|
4764 | par.pxcmy='1'; |
---|
4765 | A=imread(file_ima);%read the first image to get the size |
---|
4766 | sizim=size(A); |
---|
4767 | par.npx=num2str(sizim(2)); |
---|
4768 | par.npy=num2str(sizim(1)); |
---|
4769 | time=get(handles.displ_filebase,'UserData'); %get the set of times |
---|
4770 | par.gridname=get(handles.grid_civ2,'String'); |
---|
4771 | par.gridflag='y'; |
---|
4772 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
4773 | par.gridname='nogrid'; |
---|
4774 | par.gridflag='n'; |
---|
4775 | end |
---|
4776 | |
---|
4777 | %------------------------------------------------------------------------ |
---|
4778 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
4779 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles) |
---|
4780 | %------------------------------------------------------------------------ |
---|
4781 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4782 | global civ1_exe Civ_exe sge%name of the executable for civ1 calculation |
---|
4783 | |
---|
4784 | %changes : filename_cmx -> filename ( no extension ) |
---|
4785 | |
---|
4786 | if isequal(par.Dt,'0') |
---|
4787 | par.Dt='1' ;%case of 'displacement' mode |
---|
4788 | end |
---|
4789 | % |
---|
4790 | % textcmx={'############## CMX file';... |
---|
4791 | % ['FirstImage ' par.filename_ima_a];... |
---|
4792 | % ['LastImage ' par.filename_ima_b];... |
---|
4793 | % 'XX' ;... |
---|
4794 | % ['Mask ' par.maskflag] ;... |
---|
4795 | % ['MaskName ' par.maskname];... |
---|
4796 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
4797 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
4798 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
4799 | % ['RO ' par.rho];... |
---|
4800 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
4801 | % 'XX 1.0';... |
---|
4802 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
4803 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
4804 | % 'XX 1';... |
---|
4805 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
4806 | % ['Grid ' par.gridflag];... |
---|
4807 | % ['GridName ' par.gridname] ;... |
---|
4808 | % 'XX 85';... |
---|
4809 | % 'XX 1.0';... |
---|
4810 | % 'XX 1.0';... |
---|
4811 | % 'Hart 1';... |
---|
4812 | % 'DecimalShift 0';... |
---|
4813 | % 'Deformation 0';... |
---|
4814 | % 'CorrelationMin 0';... |
---|
4815 | % 'IntensityMin 0';... |
---|
4816 | % 'SeuilImage n';... |
---|
4817 | % 'SeuilImageValues 0 4096';... |
---|
4818 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
4819 | % 'ImageUsedBefore null null'}; |
---|
4820 | % |
---|
4821 | % textout=char(textcmx); |
---|
4822 | |
---|
4823 | fid=fopen([filename '.cmx'],'w'); |
---|
4824 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
4825 | fprintf(fid, ['FirstImage ' par.filename_ima_a '\n' ]); |
---|
4826 | fprintf(fid, ['LastImage ' par.filename_ima_b '\n' ]); |
---|
4827 | fprintf(fid, ['XX' '\n' ]); |
---|
4828 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
4829 | fprintf(fid, ['MaskName ' par.maskname '\n' ]); |
---|
4830 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
4831 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
4832 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
4833 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
4834 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
4835 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4836 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
4837 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
4838 | fprintf(fid, ['XX 1' '\n' ]); |
---|
4839 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
4840 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
4841 | fprintf(fid, ['GridName ' par.gridname '\n' ]); |
---|
4842 | fprintf(fid, ['XX 85' '\n' ]); |
---|
4843 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4844 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4845 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
4846 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
4847 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
4848 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
4849 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
4850 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
4851 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
4852 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
4853 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
4854 | fclose(fid); |
---|
4855 | |
---|
4856 | if sge |
---|
4857 | cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
4858 | else |
---|
4859 | cmd_CIV1=[civ1_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
4860 | end |
---|
4861 | if(isunix) |
---|
4862 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
4863 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
4864 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' namelog '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
4865 | else |
---|
4866 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' namelog '.civ1.log']; |
---|
4867 | end |
---|
4868 | |
---|
4869 | %------------------------------------------------------------------------ |
---|
4870 | % --- CIV1 Unified |
---|
4871 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par) |
---|
4872 | %------------------------------------------------------------------------ |
---|
4873 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4874 | global civ1_exe Civ_exe%name of the executable for civ1 calculation |
---|
4875 | |
---|
4876 | civ1.image1=par.filename_ima_a; |
---|
4877 | civ1.image2=par.filename_ima_b; |
---|
4878 | civ1.imageSize_X=par.npx; |
---|
4879 | civ1.imageSize_Y=par.npy; |
---|
4880 | civ1.outputFileName=[filename '.nc']; |
---|
4881 | civ1.correlationBoxesSize_X=par.ibx; |
---|
4882 | civ1.correlationBoxesSize_Y=par.iby; |
---|
4883 | civ1.searchBoxesSize_X=par.isx; |
---|
4884 | civ1.searchBoxesSize_Y=par.isy; |
---|
4885 | civ1.globalShift_X=par.shiftx; |
---|
4886 | civ1.globalShift_Y=par.shifty; |
---|
4887 | civ1.ro=par.rho; |
---|
4888 | civ1.hart='y'; |
---|
4889 | if isequal(par.gridflag,'y') |
---|
4890 | civ1.grid=par.gridname; |
---|
4891 | else |
---|
4892 | civ1.grid='n'; |
---|
4893 | civ1.gridSpacing_X=par.dx; |
---|
4894 | civ1.gridSpacing_Y=par.dy; |
---|
4895 | end |
---|
4896 | if isequal(par.maskflag,'y') |
---|
4897 | civ1.mask=par.maskname; |
---|
4898 | end |
---|
4899 | civ1.dt=par.Dt; |
---|
4900 | civ1.unit='pixel'; |
---|
4901 | civ1.absolut_time_T0=par.T0; |
---|
4902 | civ1.pixcmx=par.pxcmx; |
---|
4903 | civ1.pixcmy=par.pxcmy; |
---|
4904 | civ1.convectFlow='n'; |
---|
4905 | |
---|
4906 | xml_civ1_parameters=civ1; |
---|
4907 | |
---|
4908 | %------------------------------------------------------------------------ |
---|
4909 | % --- CIV2 Unified |
---|
4910 | function civ2=BATCH_CIV2_Unified(filename,namelog,par) |
---|
4911 | %------------------------------------------------------------------------ |
---|
4912 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4913 | global civ2_exe Civ_exe%name of the executable for civ1 calculation |
---|
4914 | |
---|
4915 | civ2.image1=par.filename_ima_a; |
---|
4916 | civ2.image2=par.filename_ima_b; |
---|
4917 | civ2.imageSize_X=par.npx; |
---|
4918 | civ2.imageSize_Y=par.npy; |
---|
4919 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
4920 | civ2.outputFileName=[filename '.nc']; |
---|
4921 | civ2.correlationBoxesSize_X=par.ibx; |
---|
4922 | civ2.correlationBoxesSize_Y=par.iby; |
---|
4923 | civ2.ro=par.rho; |
---|
4924 | %civ2.decimalShift=par.decimal; |
---|
4925 | %civ2.deformation=par.deformation; |
---|
4926 | if isequal(par.decimal,'1') |
---|
4927 | civ2.decimalShift='y'; |
---|
4928 | else |
---|
4929 | civ2.decimalShift='n'; |
---|
4930 | end |
---|
4931 | if isequal(par.deformation,'1') |
---|
4932 | civ2.deformation='y'; |
---|
4933 | else |
---|
4934 | civ2.deformation='n'; |
---|
4935 | end |
---|
4936 | if isequal(par.gridflag,'y') |
---|
4937 | civ2.grid=par.gridname; |
---|
4938 | else |
---|
4939 | civ2.grid='n'; |
---|
4940 | civ2.gridSpacing_X=par.dx; |
---|
4941 | civ2.gridSpacing_Y=par.dy; |
---|
4942 | end |
---|
4943 | civ2.gridSpacing_X='10'; |
---|
4944 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
4945 | if isequal(par.maskflag,'y') |
---|
4946 | civ2.mask=par.maskname; |
---|
4947 | else |
---|
4948 | civ2.mask='n'; |
---|
4949 | end |
---|
4950 | civ2.dt=par.Dt; |
---|
4951 | civ2.unit='pixel'; |
---|
4952 | civ2.absolut_time_T0=par.T0; |
---|
4953 | civ2.pixcmx=par.pxcmx; |
---|
4954 | civ2.pixcmy=par.pxcmy; |
---|
4955 | civ2.convectFlow='n'; |
---|
4956 | civ2.pixcmx=par.pxcmx; |
---|
4957 | civ2.pixcmy=par.pxcmy; |
---|
4958 | civ2.convectFlow='n'; |
---|
4959 | |
---|
4960 | %------------------------------------------------------------------------ |
---|
4961 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
4962 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par) |
---|
4963 | %------------------------------------------------------------------------ |
---|
4964 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4965 | global civ2_exe sge%name of the executable for civ1 calculation |
---|
4966 | if isequal(par.Dt,'0') |
---|
4967 | par.Dt='1' ;%case of 'displacement' mode |
---|
4968 | end |
---|
4969 | textcmx=['############## CMX file' '\n'... |
---|
4970 | ['FirstImage ' par.filename_ima_a] '\n'... |
---|
4971 | ['LastImage ' par.filename_ima_b] '\n'... |
---|
4972 | 'XX' '\n'... |
---|
4973 | ['Mask ' par.maskflag] '\n'... |
---|
4974 | ['MaskName ' par.maskname] '\n'... |
---|
4975 | ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
4976 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
4977 | ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
4978 | ['RO ' par.rho] '\n'... |
---|
4979 | ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
4980 | 'XX 1.0' '\n'... |
---|
4981 | ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
4982 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
4983 | 'XX 1' '\n'... |
---|
4984 | ['ShiftXY 0 0'] '\n'... |
---|
4985 | ['Grid ' par.gridflag] '\n'... |
---|
4986 | ['GridName ' par.gridname] '\n'... |
---|
4987 | 'XX 85' '\n'... |
---|
4988 | 'XX 1.0' '\n'... |
---|
4989 | 'XX 1.0' '\n'... |
---|
4990 | 'Hart 1' '\n'... |
---|
4991 | ['DecimalShift ' par.decimal] '\n'... |
---|
4992 | ['Deformation ' par.deformation] '\n'... |
---|
4993 | 'CorrelationMin 0' '\n'... |
---|
4994 | 'IntensityMin 0' '\n'... |
---|
4995 | 'SeuilImage n' '\n'... |
---|
4996 | 'SeuilImageValues 0 4096' '\n'... |
---|
4997 | ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
4998 | ['ImageUsedBefore ' par.filename_nc1]]; |
---|
4999 | textout=char(textcmx); |
---|
5000 | fid=fopen([filename_cmx '2'],'w'); |
---|
5001 | fprintf(fid,textout); |
---|
5002 | fclose(fid) |
---|
5003 | if sge |
---|
5004 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
5005 | else |
---|
5006 | cmd_CIV2=[civ2_exe ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
5007 | end |
---|
5008 | |
---|
5009 | %------------------------------------------------------------------------ |
---|
5010 | % --- Executes on button press in HELP. |
---|
5011 | function HELP_Callback(hObject, eventdata, handles) |
---|
5012 | %------------------------------------------------------------------------ |
---|
5013 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
5014 | pathelp=fileparts(path_to_uvmat); |
---|
5015 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html') |
---|
5016 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
5017 | else |
---|
5018 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
5019 | web([helpfile '#civ']) |
---|
5020 | end |
---|
5021 | |
---|
5022 | %------------------------------------------------------------------------ |
---|
5023 | %--read images and convert them to the uint16 format used for PIV |
---|
5024 | function A=read_image(filename,type_ima,num,movieobject) |
---|
5025 | %------------------------------------------------------------------------ |
---|
5026 | %num is the view number needed for an avi movie |
---|
5027 | switch type_ima |
---|
5028 | case 'movie' |
---|
5029 | A=read(movieobject,num); |
---|
5030 | case 'avi' |
---|
5031 | mov=aviread(filename,num); |
---|
5032 | A=frame2im(mov(1)); |
---|
5033 | case 'multimage' |
---|
5034 | A=imread(filename,num); |
---|
5035 | case 'image' |
---|
5036 | A=imread(filename); |
---|
5037 | end |
---|
5038 | siz=size(A); |
---|
5039 | if length(siz)==3;%color images |
---|
5040 | A=sum(double(A),3); |
---|
5041 | A=uint16(A); |
---|
5042 | end |
---|
5043 | |
---|
5044 | %------------------------------------------------------------------------ |
---|
5045 | function ref_i_Callback(hObject, eventdata, handles) |
---|
5046 | %------------------------------------------------------------------------ |
---|
5047 | mode_list=get(handles.mode,'String'); |
---|
5048 | mode_value=get(handles.mode,'Value'); |
---|
5049 | mode=mode_list{mode_value}; |
---|
5050 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
5051 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
5052 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
5053 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
5054 | end |
---|
5055 | |
---|
5056 | %------------------------------------------------------------------------ |
---|
5057 | function ref_j_Callback(hObject, eventdata, handles) |
---|
5058 | %------------------------------------------------------------------------ |
---|
5059 | mode_list=get(handles.mode,'String'); |
---|
5060 | mode_value=get(handles.mode,'Value'); |
---|
5061 | mode=mode_list{mode_value}; |
---|
5062 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
5063 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
5064 | end |
---|
5065 | if isequal(mode,'series(Dj)') || ... |
---|
5066 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
5067 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
5068 | end |
---|
5069 | |
---|
5070 | %------------------------------------------------------------------------ |
---|
5071 | % --- Executes on button press in compare. |
---|
5072 | function compare_Callback(hObject, eventdata, handles) |
---|
5073 | %------------------------------------------------------------------------ |
---|
5074 | test=get(handles.compare,'Value'); |
---|
5075 | if test==2 || test==3 |
---|
5076 | filebase=get(handles.displ_filebase,'String'); |
---|
5077 | browse=get(handles.browse_root,'Userdata'); |
---|
5078 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
5079 | set(handles.browse_root,'UserData',browse); |
---|
5080 | set(handles.sub_txt,'Visible','on') |
---|
5081 | set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible |
---|
5082 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
5083 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
5084 | set(handles.mode,'Visible','off') |
---|
5085 | if test==2 |
---|
5086 | set(handles.mode,'Visible','off') |
---|
5087 | else |
---|
5088 | set(handles.mode,'Visible','on') |
---|
5089 | end |
---|
5090 | |
---|
5091 | % open an image file with the browser |
---|
5092 | ind_opening=1;%default |
---|
5093 | browse.incr_pair=[0 0]; %default |
---|
5094 | oldfile=get(handles.displ_filebase,'String'); |
---|
5095 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
5096 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
5097 | '*.*', 'All Files (*.*)'}; |
---|
5098 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
5099 | fileinput=[PathName FileName];%complete file name |
---|
5100 | sizf=size(fileinput); |
---|
5101 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
5102 | [path,name,ext]=fileparts(fileinput); |
---|
5103 | [path1]=fileparts(filebase); |
---|
5104 | if ~strcmp(path1,path) |
---|
5105 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
5106 | return |
---|
5107 | end |
---|
5108 | set(handles.displ_filebase2,'String',name); |
---|
5109 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
5110 | browse=get(handles.browse_root,'UserData'); |
---|
5111 | browse.nom_type_ima_1=nom_type; |
---|
5112 | set(handles.browse_root,'UserData',browse) |
---|
5113 | |
---|
5114 | %check image extension |
---|
5115 | if ~strcmp(ext,get(handles.ext_ima,'String')) |
---|
5116 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
5117 | return |
---|
5118 | end |
---|
5119 | |
---|
5120 | %check image size |
---|
5121 | A=imread(fileinput); |
---|
5122 | npxy=get(handles.ext_ima,'UserData'); |
---|
5123 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
5124 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
5125 | return |
---|
5126 | end |
---|
5127 | else |
---|
5128 | set(handles.mode,'Visible','on') |
---|
5129 | set(handles.displ_filebase2,'Visible','Off'); |
---|
5130 | set(handles.sub_txt,'Visible','off') |
---|
5131 | set(handles.displ_filebase2,'String',[]); |
---|
5132 | mode_store=get(handles.compare,'UserData'); |
---|
5133 | set(handles.mode,'String',mode_store) |
---|
5134 | set(handles.test_stereo1,'Value',0) |
---|
5135 | set(handles.test_stereo2,'Value',0) |
---|
5136 | end |
---|
5137 | mode_Callback(hObject, eventdata, handles) |
---|
5138 | |
---|
5139 | %------------------------------------------------------------------------ |
---|
5140 | % --- Executes on button press in get_ref_fix1. |
---|
5141 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
5142 | %------------------------------------------------------------------------ |
---|
5143 | filebase=get(handles.displ_filebase,'String'); |
---|
5144 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
5145 | {'*.nc', ' (*.nc)'; |
---|
5146 | '*.nc', 'netcdf files '; ... |
---|
5147 | '*.*', 'All Files (*.*)'}, ... |
---|
5148 | 'Pick a file',filebase); |
---|
5149 | |
---|
5150 | fileinput=[PathName FileName]; |
---|
5151 | sizf=size(fileinput); |
---|
5152 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
5153 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
5154 | ref.filebase=fullfile(Path,File); |
---|
5155 | ref.num_a=stra2num(str_a); |
---|
5156 | ref.num_b=stra2num(str_b); |
---|
5157 | ref.num1=str2num(field_count); |
---|
5158 | ref.num2=str2num(str2); |
---|
5159 | browse=[];%initialisation |
---|
5160 | if ~isequal(ref.ext,'.nc') |
---|
5161 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
5162 | return |
---|
5163 | end |
---|
5164 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
5165 | set(handles.ref_fix1,'UserData',ref) |
---|
5166 | menu_field{1}='civ1'; |
---|
5167 | Data=nc2struct(fileinput,[]); |
---|
5168 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
5169 | menu_field{2}='filter1'; |
---|
5170 | end |
---|
5171 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
5172 | menu_field{3}='civ2'; |
---|
5173 | end |
---|
5174 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
5175 | menu_field{4}='filter2'; |
---|
5176 | end |
---|
5177 | set(handles.field_ref1,'String',menu_field); |
---|
5178 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
5179 | set(handles.inf_sup1,'Value',2); |
---|
5180 | set(handles.thresh_vel,'String','1');%default threshold |
---|
5181 | set(handles.ref_fix1,'Enable','on') |
---|
5182 | |
---|
5183 | %------------------------------------------------------------------------ |
---|
5184 | % --- Executes on button press in get_ref_fix2. |
---|
5185 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
5186 | %------------------------------------------------------------------------ |
---|
5187 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
5188 | filebase=get(handles.displ_filebase,'String'); |
---|
5189 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
5190 | {'*.nc', ' (*.nc)'; |
---|
5191 | '*.nc', 'netcdf files '; ... |
---|
5192 | '*.*', 'All Files (*.*)'}, ... |
---|
5193 | 'Pick a file',filebase); |
---|
5194 | fileinput=[PathName FileName]; |
---|
5195 | sizf=size(fileinput); |
---|
5196 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
5197 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
5198 | ref.filebase=fullfile(Path,File); |
---|
5199 | ref.num_a=stra2num(str_a); |
---|
5200 | ref.num_b=stra2num(str_b); |
---|
5201 | ref.num1=str2num(field_count); |
---|
5202 | ref.num2=str2num(str2); |
---|
5203 | browse=[];%initialisation |
---|
5204 | if ~isequal(ref.ext,'.nc') |
---|
5205 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
5206 | return |
---|
5207 | end |
---|
5208 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
5209 | set(handles.ref_fix2,'UserData',ref) |
---|
5210 | menu_field{1}='civ1'; |
---|
5211 | Data=nc2struct(fileinput,[]); |
---|
5212 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
5213 | menu_field{2}='filter1'; |
---|
5214 | end |
---|
5215 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
5216 | menu_field{3}='civ2'; |
---|
5217 | end |
---|
5218 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
5219 | menu_field{4}='filter2'; |
---|
5220 | end |
---|
5221 | set(handles.field_ref2,'String',menu_field); |
---|
5222 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
5223 | set(handles.inf_sup2,'Value',2); |
---|
5224 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
5225 | set(handles.ref_fix2,'Enable','on') |
---|
5226 | set(handles.ref_fix2,'Visible','on') |
---|
5227 | set(handles.field_ref2,'Visible','on') |
---|
5228 | else |
---|
5229 | set(handles.ref_fix2,'Visible','off') |
---|
5230 | set(handles.field_ref2,'Visible','off') |
---|
5231 | end |
---|
5232 | |
---|
5233 | %------------------------------------------------------------------------ |
---|
5234 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
5235 | %------------------------------------------------------------------------ |
---|
5236 | set(handles.inf_sup1,'Value',1); |
---|
5237 | set(handles.field_ref1,'Value',1) |
---|
5238 | set(handles.field_ref1,'String',{' '}) |
---|
5239 | set(handles.ref_fix1,'UserData',[]); |
---|
5240 | set(handles.ref_fix1,'String',''); |
---|
5241 | set(handles.thresh_vel1,'String','0'); |
---|
5242 | |
---|
5243 | %------------------------------------------------------------------------ |
---|
5244 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
5245 | %------------------------------------------------------------------------ |
---|
5246 | set(handles.inf_sup2,'Value',1); |
---|
5247 | set(handles.field_ref2,'Value',1) |
---|
5248 | set(handles.field_ref2,'String',{' '}) |
---|
5249 | set(handles.ref_fix2,'UserData',[]); |
---|
5250 | set(handles.ref_fix2,'String',''); |
---|
5251 | set(handles.thresh_vel2,'String','0'); |
---|
5252 | |
---|
5253 | %------------------------------------------------------------------------ |
---|
5254 | % transform letters to numbers |
---|
5255 | function numres=stra2num(str) |
---|
5256 | %------------------------------------------------------------------------ |
---|
5257 | numres=double(str)-96; |
---|
5258 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
5259 | numres=str2num(str); |
---|
5260 | end |
---|
5261 | |
---|
5262 | %------------------------------------------------------------------------ |
---|
5263 | % --- Executes on button press in test_stereo1. |
---|
5264 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
5265 | %------------------------------------------------------------------------ |
---|
5266 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
5267 | set(handles.subdomain_patch1,'Visible','on') |
---|
5268 | set(handles.rho_patch1,'Visible','on') |
---|
5269 | else |
---|
5270 | set(handles.subdomain_patch1,'Visible','off') |
---|
5271 | set(handles.rho_patch1,'Visible','off') |
---|
5272 | end |
---|
5273 | |
---|
5274 | %------------------------------------------------------------------------ |
---|
5275 | % --- Executes on button press in test_stereo2. |
---|
5276 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
5277 | %------------------------------------------------------------------------ |
---|
5278 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
5279 | set(handles.subdomain_patch2,'Visible','on') |
---|
5280 | set(handles.rho_patch2,'Visible','on') |
---|
5281 | else |
---|
5282 | set(handles.subdomain_patch2,'Visible','off') |
---|
5283 | set(handles.rho_patch2,'Visible','off') |
---|
5284 | end |
---|
5285 | |
---|
5286 | %------------------------------------------------------------------------ |
---|
5287 | % --- Executes on button press in ImaThreshold. |
---|
5288 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
5289 | %------------------------------------------------------------------------ |
---|
5290 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
5291 | set(handles.MinIma,'Visible','on') |
---|
5292 | set(handles.MaxIma,'Visible','on') |
---|
5293 | else |
---|
5294 | set(handles.MinIma,'Visible','off') |
---|
5295 | set(handles.MaxIma,'Visible','off') |
---|
5296 | end |
---|
5297 | |
---|
5298 | %------------------------------------------------------------------------ |
---|
5299 | % --- Executes on button press in ImaThreshold2. |
---|
5300 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
5301 | %------------------------------------------------------------------------ |
---|
5302 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
5303 | set(handles.MinIma2,'Visible','on') |
---|
5304 | set(handles.MaxIma2,'Visible','on') |
---|
5305 | else |
---|
5306 | set(handles.MinIma2,'Visible','off') |
---|
5307 | set(handles.MaxIma2,'Visible','off') |
---|
5308 | end |
---|
5309 | |
---|