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 27-Mar-2010 13:41:11 |
---|
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, param) |
---|
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_newBin%=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 | ext=[]; |
---|
68 | testall=0; |
---|
69 | browse=[]; |
---|
70 | %default input parameters: |
---|
71 | num1=1; % set of field i numbers |
---|
72 | num2=2; % set of field i numbers |
---|
73 | num_a=1; % set of field j numbers (fields a) |
---|
74 | num_b=1; % second set of field j numbers (fields b) |
---|
75 | subdir='A'; % subdir for the netcdf result files |
---|
76 | ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
77 | %load the initial parameters if the interface is started from uvmat |
---|
78 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
79 | filebase=param.RootName; |
---|
80 | nom_type_read=param.NomType; |
---|
81 | num1=param.num1; |
---|
82 | num2=param.num2; |
---|
83 | num_a=param.num_a; |
---|
84 | num_b=param.num_b; |
---|
85 | subdir=param.SubDir; |
---|
86 | ind_opening=param.IndOpening; |
---|
87 | ext=param.ImaExt; |
---|
88 | end |
---|
89 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||... |
---|
90 | strcmp(lower(ext),'.avi'));%if an image file has been opened by uvmat |
---|
91 | set(handles.ImaExt,'String',ext) |
---|
92 | if exist('nom_type_read','var') |
---|
93 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
94 | end |
---|
95 | elseif isequal(ext,'.nc') |
---|
96 | if exist('nom_type_read','var') |
---|
97 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
98 | end |
---|
99 | end |
---|
100 | set(handles.RootName,'String',filebase); |
---|
101 | set(handles.ImaDoc,'UserData',testall); |
---|
102 | set(handles.ImaDoc,'String',ext) |
---|
103 | |
---|
104 | %read names of the .exe file to adjust the interface according to |
---|
105 | %available binaries |
---|
106 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
107 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
108 | errormsg=[];%default error message |
---|
109 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
110 | if exist(xmlfile,'file') |
---|
111 | try |
---|
112 | t=xmltree(xmlfile); |
---|
113 | sparam=convert(t); |
---|
114 | catch |
---|
115 | errormsg={[' Unable to read the file PARAM.xml defining the civx binaries:']; lasterr}; |
---|
116 | end |
---|
117 | else |
---|
118 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
119 | end |
---|
120 | |
---|
121 | if ~isempty(errormsg) |
---|
122 | msgbox_uvmat('ERROR',errormsg); |
---|
123 | end |
---|
124 | % patch_newBin=''; |
---|
125 | test_batch=0;%default: ,no batch mode available |
---|
126 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
127 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
128 | end |
---|
129 | % if isfield(sparam,'PatchNewBin') |
---|
130 | % patch_newBin=sparam.PatchNewBin; |
---|
131 | % end |
---|
132 | % if isfield(sparam,'SGE') |
---|
133 | % sge=str2double(sparam.SGE); |
---|
134 | % end |
---|
135 | % test_batch=sge;%default |
---|
136 | if test_batch==0 |
---|
137 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
138 | end |
---|
139 | set(handles.subdir_civ1,'String',subdir)%default subdir on which uvmat was working |
---|
140 | set(handles.subdir_civ2,'String',subdir)%default subdir on which uvmat was working |
---|
141 | |
---|
142 | %initiate advised operations |
---|
143 | if isequal(ind_opening,[]) |
---|
144 | ind_opening=1; % default |
---|
145 | end |
---|
146 | % set default operation options |
---|
147 | enable_civ1(handles,'off') |
---|
148 | enable_civ2(handles,'off') |
---|
149 | enable_pair1(handles,'on') |
---|
150 | enable_fix1(handles,'off') |
---|
151 | desable_patch1(handles) |
---|
152 | desable_fix2(handles) |
---|
153 | desable_patch2(handles) |
---|
154 | set(handles.CIV1,'Value',0) |
---|
155 | set(handles.FIX1,'Value',0) |
---|
156 | set(handles.PATCH1,'Value',0) |
---|
157 | set(handles.CIV2,'Value',0) |
---|
158 | set(handles.FIX2,'Value',0) |
---|
159 | set(handles.PATCH2,'Value',0) |
---|
160 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
161 | if isequal(ind_opening,1) |
---|
162 | set(handles.CIV1,'Value',1) |
---|
163 | enable_civ1(handles,'on') |
---|
164 | elseif isequal(ind_opening,2) |
---|
165 | set(handles.FIX1,'Value',1) |
---|
166 | enable_fix1(handles,'on') |
---|
167 | elseif isequal(ind_opening,3) |
---|
168 | set(handles.PATCH1,'Value',1) |
---|
169 | enable_patch1(handles) |
---|
170 | elseif isequal(ind_opening,4) |
---|
171 | set(handles.CIV2,'Value',1) |
---|
172 | enable_civ2(handles,1) |
---|
173 | elseif isequal(ind_opening,5) |
---|
174 | set(handles.FIX2,'Value',1) |
---|
175 | enable_fix2(handles) |
---|
176 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
177 | set(handles.list_pair_civ2,'Enable','On') |
---|
178 | set(handles.list_pair_civ2,'Enable','On') |
---|
179 | enable_pair1(handles,'off') |
---|
180 | elseif isequal(ind_opening,6) |
---|
181 | set(handles.PATCH2,'Value',1) |
---|
182 | enable_patch2(handles) |
---|
183 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
184 | set(handles.list_pair_civ2,'Enable','On') |
---|
185 | enable_pair1(handles,'off') |
---|
186 | end |
---|
187 | |
---|
188 | % set the range of fields (1:1 by default) and selected pair |
---|
189 | if isempty(num2)||isequal(num2,num1) |
---|
190 | num_ref_i=num1; |
---|
191 | else |
---|
192 | num_ref_i=floor((num1+num2)/2); |
---|
193 | browse.incr_pair(1)=num2-num1; |
---|
194 | browse.incr_pair(2)=0; |
---|
195 | end |
---|
196 | if isempty(num_b)||isequal(num_a,num_b) |
---|
197 | if isempty(num_a) |
---|
198 | num_ref_j=1; |
---|
199 | else |
---|
200 | num_ref_j=num_a; |
---|
201 | end |
---|
202 | else |
---|
203 | num_ref_j=floor((num_a+num_b)/2); |
---|
204 | browse.incr_pair(2)=num_b-num_a; |
---|
205 | end |
---|
206 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
207 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
208 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
209 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
210 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
211 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
212 | set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
213 | set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
214 | set(handles.browse_root,'UserData',browse); |
---|
215 | if exist('param','var')%varargin the interface is opened from uvmat |
---|
216 | RootName_Callback(hObject, eventdata, handles); |
---|
217 | end |
---|
218 | |
---|
219 | set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
220 | set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
221 | set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
222 | set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
223 | |
---|
224 | %------------------------------------------------------------------------ |
---|
225 | % --- Outputs from this function are returned to the command line. |
---|
226 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
227 | %------------------------------------------------------------------------ |
---|
228 | % varargout cell array for returning output args (see VARARGOUT); |
---|
229 | % hObject handle to figure |
---|
230 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
231 | % handles structure with handles and user data (see GUIDATA) |
---|
232 | % Get default command line output from handles structure |
---|
233 | varargout{1} = handles.output; |
---|
234 | |
---|
235 | %------------------------------------------------------------------------ |
---|
236 | % --- Executes on button press in browse_root. |
---|
237 | function browse_root_Callback(hObject, eventdata, handles) |
---|
238 | %------------------------------------------------------------------------ |
---|
239 | %get the input file properties |
---|
240 | filebase=get(handles.RootName,'String'); |
---|
241 | oldfile=''; %default |
---|
242 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
243 | dir_perso=prefdir; |
---|
244 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
245 | display(profil_perso) |
---|
246 | if exist(profil_perso,'file') |
---|
247 | h=load (profil_perso); |
---|
248 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
249 | oldfile=h.filebase; |
---|
250 | end |
---|
251 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
252 | oldfile=h.RootPath; |
---|
253 | end |
---|
254 | end |
---|
255 | else |
---|
256 | oldfile=filebase; |
---|
257 | end |
---|
258 | testall=get(handles.ImaDoc,'UserData'); |
---|
259 | ind_opening=1;%default |
---|
260 | browse.incr_pair=[0 0]; %default |
---|
261 | if testall |
---|
262 | menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
263 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'}; |
---|
264 | else % menu selecting only .civ or .avi files |
---|
265 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
266 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
267 | '*.*', 'All Files (*.*)'}; |
---|
268 | end |
---|
269 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
270 | fileinput=[PathName FileName];%complete file name |
---|
271 | sizf=size(fileinput); |
---|
272 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
273 | [path,name,ext]=fileparts(fileinput); |
---|
274 | testeditxml=0; |
---|
275 | if isequal(ext,'.xml') |
---|
276 | testeditxml=1; |
---|
277 | t_browse=xmltree(fileinput); |
---|
278 | head_element=get(t_browse,1); |
---|
279 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
280 | testeditxml=0; |
---|
281 | end |
---|
282 | end |
---|
283 | if testeditxml==1 || isequal(ext,'.xls') |
---|
284 | heditxml=editxml({fileinput}); |
---|
285 | set(heditxml,'Tag','browser') |
---|
286 | waitfor(heditxml,'Tag','idle') |
---|
287 | if ~ishandle(heditxml) |
---|
288 | return |
---|
289 | end |
---|
290 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
291 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
292 | fileinput=get(attr,'UserData'); |
---|
293 | if ~exist(fileinput,'file') |
---|
294 | return |
---|
295 | end |
---|
296 | end |
---|
297 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
298 | filebase=fullfile(RootPath,RootFile); |
---|
299 | % if isequal(nom_type,'*')% all fields in a single file ( movie files) |
---|
300 | % num_i1=1;num_i2=1;num_j1=1;num_j2=1; |
---|
301 | % else |
---|
302 | num_i1=stra2num(str1); |
---|
303 | if isempty(num_i1),num_i1=1;end |
---|
304 | num_i2=stra2num(str2); |
---|
305 | if isempty(num_i2),num_i2=1;end |
---|
306 | num_j1=stra2num(str_a); |
---|
307 | if isempty(num_j1),num_j1=1;end |
---|
308 | num_j2=stra2num(str_b); |
---|
309 | if isempty(num_j2),num_j2=1;end |
---|
310 | if isequal(get(handles.compare,'Value'),1) |
---|
311 | browse=[];%initialisation |
---|
312 | else |
---|
313 | browse=get(handles.browse_root,'UserData'); |
---|
314 | end |
---|
315 | if length(ext)>1 && (~isempty(imformats(ext([2:end])))||... |
---|
316 | isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat |
---|
317 | set(handles.ImaExt,'String',ext) |
---|
318 | browse.nom_type_ima=nom_type; |
---|
319 | browse.field_count=num_i1; |
---|
320 | % A=imread(fileinput); |
---|
321 | % npxy=size(A); |
---|
322 | % set(handles.ImaExt,'UserData',npxy) |
---|
323 | end |
---|
324 | set(handles.ImaDoc,'String',ext); |
---|
325 | |
---|
326 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
327 | if isequal(ext,'.nc') |
---|
328 | browse.nom_type_nc=nom_type; |
---|
329 | ind_opening=2;% propose 'fix' as the default option |
---|
330 | Data=nc2struct(fileinput,[]); |
---|
331 | if isfield(Data,'absolut_time_T0')%test for civx files |
---|
332 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
333 | ind_opening=3; |
---|
334 | end |
---|
335 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
336 | ind_opening=4; |
---|
337 | end |
---|
338 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
339 | ind_opening=5; |
---|
340 | end |
---|
341 | if isfield(Data,'fix2') && isequal(Data.fix2,1) |
---|
342 | ind_opening=6; |
---|
343 | end |
---|
344 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
345 | else |
---|
346 | ind_opening=3; %GUI used only for patch |
---|
347 | testciv=0; |
---|
348 | end |
---|
349 | set(handles.subdir_civ1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
350 | set(handles.subdir_civ2,'String',subdir); |
---|
351 | browse.testciv=testciv; |
---|
352 | browse.ind_opening=ind_opening; |
---|
353 | end |
---|
354 | set(handles.RootName,'String',filebase); |
---|
355 | set(handles.ImaDoc,'String',ext); |
---|
356 | if ~isempty(num_i1) |
---|
357 | ref_i=num_i1; |
---|
358 | if ~isempty(num_i2) |
---|
359 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
360 | browse.incr_pair(1)=num_i2-num_i1; |
---|
361 | browse.incr_pair(2)=0; |
---|
362 | end |
---|
363 | set(handles.first_i,'String',num2str(ref_i)); |
---|
364 | set(handles.last_i,'String',num2str(ref_i)); |
---|
365 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
366 | set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
367 | end |
---|
368 | if isempty(num_j1) |
---|
369 | set(handles.ref_j,'String','1'); |
---|
370 | set(handles.ref_j_civ2,'String','1'); |
---|
371 | else |
---|
372 | ref_j=num_j1; |
---|
373 | if ~isempty(num_j2) |
---|
374 | ref_j=floor((num_j1+num_j2)/2); |
---|
375 | browse.incr_pair(2)=num_j2-num_j1; |
---|
376 | end |
---|
377 | set(handles.first_j,'String',num2str(ref_j)); |
---|
378 | set(handles.last_j,'String',num2str(ref_j)); |
---|
379 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
380 | set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
381 | end |
---|
382 | |
---|
383 | % set default operation options |
---|
384 | enable_civ1(handles,'off') |
---|
385 | enable_civ2(handles,'off') |
---|
386 | enable_pair1(handles,'on') |
---|
387 | enable_fix1(handles,'off') |
---|
388 | desable_patch1(handles) |
---|
389 | desable_fix2(handles) |
---|
390 | desable_patch2(handles) |
---|
391 | set(handles.CIV1,'Value',0) |
---|
392 | set(handles.FIX1,'Value',0) |
---|
393 | set(handles.PATCH1,'Value',0) |
---|
394 | set(handles.CIV2,'Value',0) |
---|
395 | set(handles.FIX2,'Value',0) |
---|
396 | set(handles.PATCH2,'Value',0) |
---|
397 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
398 | if isequal(ind_opening,1) |
---|
399 | set(handles.CIV1,'Value',1) |
---|
400 | enable_civ1(handles,'on') |
---|
401 | elseif isequal(ind_opening,2) |
---|
402 | set(handles.FIX1,'Value',1) |
---|
403 | enable_fix1(handles,'on') |
---|
404 | elseif isequal(ind_opening,3) |
---|
405 | set(handles.PATCH1,'Value',1) |
---|
406 | enable_patch1(handles) |
---|
407 | elseif isequal(ind_opening,4) |
---|
408 | set(handles.CIV2,'Value',1) |
---|
409 | enable_civ2(handles,1) |
---|
410 | elseif isequal(ind_opening,5) |
---|
411 | enable_pair1(handles,'off') |
---|
412 | set(handles.FIX2,'Value',1) |
---|
413 | enable_fix2(handles) |
---|
414 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
415 | set(handles.list_pair_civ2,'Enable','On') |
---|
416 | set(handles.list_pair_civ2,'Enable','On') |
---|
417 | elseif isequal(ind_opening,6) |
---|
418 | enable_pair1(handles,'off') |
---|
419 | set(handles.PATCH2,'Value',1) |
---|
420 | enable_patch2(handles) |
---|
421 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
422 | set(handles.list_pair_civ2,'Enable','On') |
---|
423 | end |
---|
424 | set(handles.browse_root,'UserData',browse);% store information from browser |
---|
425 | testall=isequal(menu(filtindex,1),{'*.*'}); |
---|
426 | set(handles.ImaDoc,'UserData',testall); |
---|
427 | |
---|
428 | RootName_Callback(hObject, eventdata, handles); |
---|
429 | |
---|
430 | %------------------------------------------------------------------------ |
---|
431 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
432 | %------------------------------------------------------------------------ |
---|
433 | RootName_Callback(hObject, eventdata, handles) |
---|
434 | |
---|
435 | %------------------------------------------------------------------------ |
---|
436 | % --- function activated when a new filebase (image series) is introduced |
---|
437 | function RootName_Callback(hObject, eventdata, handles) |
---|
438 | %------------------------------------------------------------------------ |
---|
439 | global test_batch |
---|
440 | set(handles.compare,'Visible','on') |
---|
441 | ext_ima=get(handles.ImaExt,'String'); |
---|
442 | nom_type_ima=[];%default |
---|
443 | field_count=1;%default |
---|
444 | nom_type_nc=[]; |
---|
445 | time=[]; |
---|
446 | TimeUnit='frame'; %default |
---|
447 | CoordUnit='px';%default |
---|
448 | pxcmx_search=[];%default |
---|
449 | pxcmy_search=[];%default |
---|
450 | filebase=get(handles.RootName,'String'); |
---|
451 | |
---|
452 | ext=get(handles.ImaDoc,'String'); |
---|
453 | browse=get(handles.browse_root,'UserData');%default |
---|
454 | if ~isempty(browse) |
---|
455 | if isfield(browse,'nom_type_ima') |
---|
456 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
457 | end |
---|
458 | if isfield(browse,'field_count') |
---|
459 | field_count=browse.field_count;% get an image index type already determined by an input file |
---|
460 | end |
---|
461 | end |
---|
462 | |
---|
463 | %default first_i and j and increments |
---|
464 | first_i=str2num(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
465 | if isempty(first_i)|| first_i < 1 |
---|
466 | first_i=1; %default first_i |
---|
467 | end |
---|
468 | last_i=str2num(get(handles.last_i,'String')); |
---|
469 | if isempty(last_i)|| last_i < first_i |
---|
470 | last_i=first_i; %default last_i |
---|
471 | end |
---|
472 | first_j=str2num(get(handles.first_j,'String')); |
---|
473 | if isempty(first_j)|| first_j < 1 |
---|
474 | first_j=1; %default first_j |
---|
475 | end |
---|
476 | last_j=str2num(get(handles.last_j,'String')); |
---|
477 | if isempty(last_j)|| last_j < first_j |
---|
478 | last_j=first_j; %default last_j |
---|
479 | end |
---|
480 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
481 | if isempty(incr_i) || incr_i < 1; |
---|
482 | set(handles.incr_i,'String','1') %default incr_i |
---|
483 | end |
---|
484 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
485 | if isempty(incr_j) || incr_j < 1; |
---|
486 | set(handles.incr_j,'String','1') %default incr_j |
---|
487 | end |
---|
488 | dt=[];%default |
---|
489 | testmode=0;%default |
---|
490 | nbfield=[]; %default |
---|
491 | nburst=[];%default |
---|
492 | pxcmx=1; |
---|
493 | pxcmy=1; |
---|
494 | |
---|
495 | %look for an image documentation file |
---|
496 | if ~isequal(ext,'.xml') && ~isequal(ext,'.civ')&& ~isequal(ext,'.avi')&& ~isequal(ext,'.AVI') |
---|
497 | if exist([filebase '.xml'],'file') |
---|
498 | ext='.xml'; |
---|
499 | elseif exist([filebase '.civxml'],'file') |
---|
500 | ext='.civxml'; |
---|
501 | elseif exist([filebase '.civ'],'file') |
---|
502 | ext='.civ'; |
---|
503 | elseif exist([filebase '.avi'],'file') |
---|
504 | ext='.avi'; |
---|
505 | elseif exist([filebase '.AVI'],'file') |
---|
506 | ext='.AVI'; |
---|
507 | end |
---|
508 | set(handles.ImaDoc,'String',ext) |
---|
509 | end |
---|
510 | |
---|
511 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
512 | mode=''; %default |
---|
513 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
514 | drawnow |
---|
515 | %read the image documentation file if found |
---|
516 | if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') |
---|
517 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
518 | set(handles.ref_j,'Visible','On') |
---|
519 | % set(handles.dt,'Visible','Off') |
---|
520 | % set(handles.root_txt,'String','') |
---|
521 | elseif isequal(ext,'.avi') || isequal(ext,'.AVI') |
---|
522 | set(handles.ref_j,'Visible','Off') |
---|
523 | % set(handles.dt,'Visible','Off') |
---|
524 | % set(handles.root_txt,'String','ref. ind.') |
---|
525 | else |
---|
526 | set(handles.ref_i,'Visible','Off') |
---|
527 | set(handles.ref_j,'Visible','Off') |
---|
528 | % set(handles.dt,'Visible','On') |
---|
529 | % set(handles.root_txt,'String','dt(ms)=') |
---|
530 | end |
---|
531 | testima_xml=0; |
---|
532 | if isequal(ext,'.civxml')%TO ABANDON |
---|
533 | [nbfield,nburst,time]=read_civxml([filebase '.civxml']); |
---|
534 | mode='pair j1-j2'; |
---|
535 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
536 | nom_type_ima='_i_j'; |
---|
537 | end |
---|
538 | elseif isequal(ext,'.xml') |
---|
539 | [XmlData,warntext]=imadoc2struct([filebase '.xml']) |
---|
540 | if isfield(XmlData,'Time') |
---|
541 | time=XmlData.Time; |
---|
542 | nbfield=size(time,1); |
---|
543 | nburst=size(time,2); |
---|
544 | end |
---|
545 | ext_ima_read=[]; |
---|
546 | nom_type_read=[]; |
---|
547 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
548 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
549 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
550 | if ~exist(fullname,'file') |
---|
551 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
552 | end |
---|
553 | end |
---|
554 | if isfield(XmlData,'TimeUnit') |
---|
555 | TimeUnit=XmlData.TimeUnit; |
---|
556 | end |
---|
557 | if isfield(XmlData,'Npx') |
---|
558 | npx=XmlData.Npx; |
---|
559 | npy=XmlData.Npy; |
---|
560 | end |
---|
561 | pxcmx_search=1; |
---|
562 | pxcmy_search=1; |
---|
563 | if isfield(XmlData,'GeometryCalib') |
---|
564 | tsai=XmlData.GeometryCalib; |
---|
565 | if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') |
---|
566 | rot2D=tsai.R([1:2],[1,2]); |
---|
567 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
568 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
569 | end |
---|
570 | if isfield(tsai,'CoordUnit') |
---|
571 | CoordUnit=tsai.CoordUnit; |
---|
572 | end |
---|
573 | end |
---|
574 | if ~isempty(ext_ima_read) && ~isempty(nom_type_read) |
---|
575 | if isempty(ext_ima) |
---|
576 | ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously |
---|
577 | else %keep the image extension |
---|
578 | if ~strcmp(ext_ima_read,ext_ima) |
---|
579 | msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image']) |
---|
580 | end |
---|
581 | end |
---|
582 | nom_type_ima=nom_type_read; |
---|
583 | end |
---|
584 | elseif isequal(ext,'.civ')% case of .civ image documentation file |
---|
585 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
586 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
587 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
588 | end |
---|
589 | % ImaExt='.png'; |
---|
590 | nom_type_ima='png_old'; |
---|
591 | elseif isequal(lower(ext),'.avi') |
---|
592 | nom_type_ima='*'; |
---|
593 | ext_ima=ext; |
---|
594 | set(handles.mode,'String',{'series(Di)'}) |
---|
595 | dt=0.04;%default |
---|
596 | if exist([filebase ext],'file')==2 |
---|
597 | info=aviinfo([filebase ext]);%read infos on the avi movie |
---|
598 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
599 | nbfield=info.NumFrames;%number of frames |
---|
600 | end |
---|
601 | time=(dt*[0:nbfield-1])';%list of image times |
---|
602 | %set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images |
---|
603 | end |
---|
604 | if isempty(time) |
---|
605 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
606 | end |
---|
607 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
608 | |
---|
609 | %get the imabe nomenclature type if not defiend by the input file nor by the xml file |
---|
610 | if isempty(nom_type_ima) |
---|
611 | %look for double image series '_i_j' |
---|
612 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
613 | if isempty(dirima) |
---|
614 | % look for images series with sub marker '_' |
---|
615 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
616 | if isempty(dirima) |
---|
617 | % look for other images series |
---|
618 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
619 | if ~isempty(dirima) |
---|
620 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
621 | end |
---|
622 | else |
---|
623 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
624 | end |
---|
625 | else |
---|
626 | [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name); |
---|
627 | end |
---|
628 | end |
---|
629 | |
---|
630 | % no image documentation file found: look for a series of existing images or .nc files |
---|
631 | if isempty(time) && ~isequal(ext,'.nc') |
---|
632 | subdir=get(handles.subdir_civ1,'String'); |
---|
633 | incr_pair=[0 0];%default |
---|
634 | if isfield(browse,'incr_pair') |
---|
635 | incr_pair=browse.incr_pair; |
---|
636 | end |
---|
637 | nbdetect=0;%test of detected images |
---|
638 | field_i=field_count; |
---|
639 | idetect=1; |
---|
640 | while idetect==1 %look for the maximum file number in the series |
---|
641 | field_i=field_i+1; |
---|
642 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
643 | if strcmp(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
644 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
645 | nbdetect=1; |
---|
646 | else |
---|
647 | idetect=(exist(imagename,'file')==2); |
---|
648 | end |
---|
649 | %SEE CASE OF NETCDF FILES |
---|
650 | nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
651 | end |
---|
652 | nb_field=field_i;% last detected field number |
---|
653 | field_i=field_count;%look for the minimum file number in the series |
---|
654 | idetect=1; |
---|
655 | while idetect==1 |
---|
656 | field_i=field_i-1; |
---|
657 | imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); |
---|
658 | if isequal(nom_type_ima,'none')||strcmp(nom_type_ima,'') |
---|
659 | idetect=0; %stop if the same image is repeated (if nom_type='none') |
---|
660 | nbdetect=1; |
---|
661 | else |
---|
662 | idetect=(exist(imagename,'file')==2); |
---|
663 | end |
---|
664 | nbdetect=nbdetect+idetect; |
---|
665 | end |
---|
666 | first_i=max(field_i+1,1); |
---|
667 | %determine the set of times and possible intervals for CIV |
---|
668 | % dt=(1/1000)*str2num(get(handles.dt,'String')); |
---|
669 | time=[0:nb_field-1]';% time=file index -1 by default |
---|
670 | set(handles.mode,'String',{'series(Di)'}) |
---|
671 | end |
---|
672 | if isequal(nom_type_ima,'none')% no file numbering used |
---|
673 | first_i=1; |
---|
674 | last_i=1; |
---|
675 | first_j=1; |
---|
676 | last_j=1; |
---|
677 | end |
---|
678 | if exist('time','var') |
---|
679 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
680 | nbfield=size(time,1); |
---|
681 | nbfield2=size(time,2); |
---|
682 | set(handles.RootName,'UserData',time); %store the set of times |
---|
683 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
684 | set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
685 | set(handles.TimeUnit,'String',TimeUnit); |
---|
686 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
687 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
688 | end |
---|
689 | end |
---|
690 | set(handles.CoordUnit,'String',CoordUnit) |
---|
691 | set(handles.calcul_search,'UserData',[pxcmx_search pxcmy_search]); |
---|
692 | % npxy=[npy npx]; |
---|
693 | set(handles.ImaExt,'String',ext_ima) |
---|
694 | set(handles.first_i,'String',num2str(first_i)); |
---|
695 | set(handles.last_i,'String',num2str(last_i));% |
---|
696 | set(handles.first_j,'String',num2str(first_j)); |
---|
697 | set(handles.last_j,'String',num2str(last_j));% |
---|
698 | browse.nom_type_ima=nom_type_ima; |
---|
699 | set(handles.browse_root,'UserData',browse)% store the nomenclature type |
---|
700 | |
---|
701 | %%%%%%%%%%% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
702 | if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
703 | set(handles.mode,'String',{'series(Di)'}) |
---|
704 | set(handles.mode,'Value',1) |
---|
705 | elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old') |
---|
706 | set(handles.mode,'String',{'pair j1-j2'}) |
---|
707 | set(handles.mode,'Value',1) |
---|
708 | elseif (nbfield==1)% simple series in j |
---|
709 | set(handles.mode,'String',{'series(Dj)'}) |
---|
710 | set(handles.mode,'Value',1) |
---|
711 | else |
---|
712 | set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
713 | if nbfield2 <= 5 |
---|
714 | set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
715 | end |
---|
716 | % else |
---|
717 | % if isequal(mode,'volume') |
---|
718 | % set(handles.mode,'Value',3) |
---|
719 | % elseif nbfield2 <= 5 |
---|
720 | % set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts |
---|
721 | % else |
---|
722 | % set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume |
---|
723 | % end |
---|
724 | end |
---|
725 | |
---|
726 | %update the subdir |
---|
727 | pathdir=fileparts(filebase);%path to the current xml file |
---|
728 | listot=dir(pathdir); |
---|
729 | idir=0; |
---|
730 | listdir={''};%default |
---|
731 | for ilist=1:length(listot) |
---|
732 | if listot(ilist).isdir |
---|
733 | name=listot(ilist).name; |
---|
734 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
735 | idir=idir+1; |
---|
736 | listdir{idir,1}=listot(ilist).name; |
---|
737 | end |
---|
738 | end |
---|
739 | end |
---|
740 | set(handles.list_subdir_civ1,'Value',1) |
---|
741 | set(handles.list_subdir_civ2,'Value',1) |
---|
742 | set(handles.list_subdir_civ1,'String',['browse...';listdir]) |
---|
743 | set(handles.list_subdir_civ2,'String',['browse...';listdir]) |
---|
744 | %check wether the current subdir exists: |
---|
745 | subdir_civ1=get(handles.subdir_civ1,'String'); |
---|
746 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
747 | |
---|
748 | mode_Callback(hObject, eventdata, handles) |
---|
749 | |
---|
750 | %%%%%% initialize waitbars and RUN button |
---|
751 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
752 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
753 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
754 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
755 | set(handles.RUN, 'Enable','On') |
---|
756 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
757 | if isequal(test_batch,1)%if batch installation is available |
---|
758 | set(handles.BATCH, 'Enable','On') |
---|
759 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
760 | end |
---|
761 | |
---|
762 | %%%%% store the root input filename for future opening |
---|
763 | dir_perso=prefdir; |
---|
764 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
765 | RootPath=fileparts(filebase); |
---|
766 | if exist(profil_perso,'file') |
---|
767 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
768 | else |
---|
769 | txt=ver; |
---|
770 | Release=txt(1).Release; |
---|
771 | relnumb=str2num(Release(3:4)); |
---|
772 | if relnumb >= 14 |
---|
773 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
774 | else |
---|
775 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
776 | end |
---|
777 | end |
---|
778 | % save(profil_perso, 'filebase'); %store the root name for future opening of uvmat |
---|
779 | set(gcf,'Pointer','arrow') |
---|
780 | |
---|
781 | %------------------------------------------------------------------------ |
---|
782 | % --- Executes on button press in mode. |
---|
783 | function mode_Callback(hObject, eventdata, handles) |
---|
784 | %------------------------------------------------------------------------ |
---|
785 | browse=get(handles.browse_root,'UserData'); |
---|
786 | compare_list=get(handles.compare,'String'); |
---|
787 | val=get(handles.compare,'Value'); |
---|
788 | compare=compare_list{val}; |
---|
789 | if strcmp(compare,'displacement') |
---|
790 | mode='displacement'; |
---|
791 | else |
---|
792 | mode_list=get(handles.mode,'String'); |
---|
793 | mode_value=get(handles.mode,'Value'); |
---|
794 | mode=mode_list{mode_value}; |
---|
795 | end |
---|
796 | displ_num=[];%default |
---|
797 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
798 | % last_i=str2num(get(handles.last_i,'String')); |
---|
799 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
800 | siztime=size(time); |
---|
801 | nbfield=siztime(1); |
---|
802 | nbfield2=siztime(2); |
---|
803 | indchosen=1; %%first pair selected by default |
---|
804 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
805 | dt=1; |
---|
806 | displ=''; |
---|
807 | index=0; |
---|
808 | numlist_a=[]; |
---|
809 | numlist_B=[]; |
---|
810 | %get all the time intervals in bursts |
---|
811 | displ_dt=1;%default |
---|
812 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
813 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
814 | for numod_b=(numod_a+1):nbfield2 |
---|
815 | index=index+1; |
---|
816 | numlist_a(index)=numod_a; |
---|
817 | numlist_b(index)=numod_b; |
---|
818 | if ~isempty(time) |
---|
819 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
820 | displ_dt(index)=dt(numod_a,numod_b); |
---|
821 | else |
---|
822 | displ_dt(index)=1; |
---|
823 | end |
---|
824 | end |
---|
825 | end |
---|
826 | [dtsort,indsort]=sort(displ_dt); |
---|
827 | if ~isempty(numlist_a) |
---|
828 | displ_num(1,:)=numlist_a(indsort); |
---|
829 | displ_num(2,:)=numlist_b(indsort); |
---|
830 | end |
---|
831 | displ_num(3,:)=0; |
---|
832 | displ_num(4,:)=0; |
---|
833 | set(handles.jtext,'Visible','Off') |
---|
834 | set(handles.first_j,'Visible','Off') |
---|
835 | set(handles.last_j,'Visible','Off') |
---|
836 | set(handles.incr_j,'Visible','Off') |
---|
837 | set(handles.nb_field2,'Visible','Off') |
---|
838 | set(handles.ref_j,'Visible','Off') |
---|
839 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
840 | for index=1:min(nbfield2-1,200) |
---|
841 | displ_num(1,index)=-floor(index/2); |
---|
842 | displ_num(2,index)=ceil(index/2); |
---|
843 | displ_num(3,index)=0; |
---|
844 | displ_num(4,index)=0; |
---|
845 | end |
---|
846 | set(handles.jtext,'Visible','On') |
---|
847 | set(handles.first_j,'Visible','On') |
---|
848 | set(handles.last_j,'Visible','On') |
---|
849 | set(handles.incr_j,'Visible','On') |
---|
850 | set(handles.nb_field2,'Visible','On') |
---|
851 | set(handles.ref_j,'Visible','On') |
---|
852 | if nbfield > 1 |
---|
853 | set(handles.itext,'Visible','On') |
---|
854 | set(handles.first_i,'Visible','On') |
---|
855 | set(handles.last_i,'Visible','On') |
---|
856 | set(handles.incr_i,'Visible','On') |
---|
857 | set(handles.nb_field,'Visible','On') |
---|
858 | set(handles.ref_i,'Visible','On') |
---|
859 | else |
---|
860 | set(handles.itext,'Visible','Off') |
---|
861 | set(handles.first_i,'Visible','Off') |
---|
862 | set(handles.last_i,'Visible','Off') |
---|
863 | set(handles.incr_i,'Visible','Off') |
---|
864 | set(handles.nb_field,'Visible','Off') |
---|
865 | set(handles.ref_i,'Visible','Off') |
---|
866 | end |
---|
867 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
868 | for index=1:200%min(nbfield-1,200) |
---|
869 | displ_num(1,index)=0; |
---|
870 | displ_num(2,index)=0; |
---|
871 | displ_num(3,index)=-floor(index/2); |
---|
872 | displ_num(4,index)=ceil(index/2); |
---|
873 | end |
---|
874 | set(handles.itext,'Visible','On') |
---|
875 | set(handles.first_i,'Visible','On') |
---|
876 | set(handles.last_i,'Visible','On') |
---|
877 | set(handles.incr_i,'Visible','On') |
---|
878 | set(handles.nb_field,'Visible','On') |
---|
879 | set(handles.ref_i,'Visible','On') |
---|
880 | if nbfield2 > 1 |
---|
881 | set(handles.jtext,'Visible','On') |
---|
882 | set(handles.first_j,'Visible','On') |
---|
883 | set(handles.last_j,'Visible','On') |
---|
884 | set(handles.incr_j,'Visible','On') |
---|
885 | set(handles.nb_field2,'Visible','On') |
---|
886 | set(handles.ref_j,'Visible','On') |
---|
887 | else |
---|
888 | set(handles.jtext,'Visible','Off') |
---|
889 | set(handles.first_j,'Visible','Off') |
---|
890 | set(handles.last_j,'Visible','Off') |
---|
891 | set(handles.incr_j,'Visible','Off') |
---|
892 | set(handles.nb_field2,'Visible','Off') |
---|
893 | set(handles.ref_j,'Visible','Off') |
---|
894 | end |
---|
895 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
896 | displ_num(1,1)=0; |
---|
897 | displ_num(2,1)=0; |
---|
898 | displ_num(3,1)=0; |
---|
899 | displ_num(4,1)=0; |
---|
900 | if nbfield > 1 |
---|
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 | else |
---|
908 | set(handles.itext,'Visible','Off') |
---|
909 | set(handles.first_i,'Visible','Off') |
---|
910 | set(handles.last_i,'Visible','Off') |
---|
911 | set(handles.incr_i,'Visible','Off') |
---|
912 | set(handles.nb_field,'Visible','Off') |
---|
913 | set(handles.ref_i,'Visible','Off') |
---|
914 | end |
---|
915 | if nbfield2 > 1 |
---|
916 | set(handles.jtext,'Visible','On') |
---|
917 | set(handles.first_j,'Visible','On') |
---|
918 | set(handles.last_j,'Visible','On') |
---|
919 | set(handles.incr_j,'Visible','On') |
---|
920 | set(handles.nb_field2,'Visible','On') |
---|
921 | set(handles.ref_j,'Visible','On') |
---|
922 | else |
---|
923 | set(handles.jtext,'Visible','Off') |
---|
924 | set(handles.first_j,'Visible','Off') |
---|
925 | set(handles.last_j,'Visible','Off') |
---|
926 | set(handles.incr_j,'Visible','Off') |
---|
927 | set(handles.nb_field2,'Visible','Off') |
---|
928 | set(handles.ref_j,'Visible','Off') |
---|
929 | end |
---|
930 | end |
---|
931 | set(handles.list_pair_civ1,'UserData',displ_num); |
---|
932 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
933 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
934 | |
---|
935 | %------------------------------------------------------------------------ |
---|
936 | % determine the menu for civ1 pairs depending on existing netcdf file at the middle of |
---|
937 | % the field series set by first_i, incr, last_i |
---|
938 | function find_netcpair_civ1(hObject, eventdata, handles) |
---|
939 | %------------------------------------------------------------------------ |
---|
940 | set(gcf,'Pointer','watch') |
---|
941 | %nomenclature types |
---|
942 | filebase=get(handles.RootName,'String'); |
---|
943 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
944 | browse=get(handles.browse_root,'UserData'); |
---|
945 | compare_list=get(handles.compare,'String'); |
---|
946 | val=get(handles.compare,'Value'); |
---|
947 | compare=compare_list{val}; |
---|
948 | if strcmp(compare,'displacement') |
---|
949 | mode='displacement'; |
---|
950 | else |
---|
951 | mode_list=get(handles.mode,'String'); |
---|
952 | mode_value=get(handles.mode,'Value'); |
---|
953 | mode=mode_list{mode_value}; |
---|
954 | end |
---|
955 | |
---|
956 | % nomenclature type of the .nc files |
---|
957 | nom_type_ima=[];%default |
---|
958 | if isfield(browse,'nom_type_ima') |
---|
959 | nom_type_ima=browse.nom_type_ima; |
---|
960 | end |
---|
961 | |
---|
962 | %determine nom_type_nc: |
---|
963 | nom_type_nc=[];%default |
---|
964 | if isfield(browse,'nom_type_nc') |
---|
965 | nom_type_nc=browse.nom_type_nc; |
---|
966 | end |
---|
967 | if isempty(nom_type_nc) |
---|
968 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
969 | end |
---|
970 | browse.nom_type_nc=nom_type_nc; |
---|
971 | set(handles.browse_root,'UserData',browse) |
---|
972 | |
---|
973 | %reads .nc subdirectoy and image numbers from the interface |
---|
974 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
975 | % first_i=str2num(get(handles.first_i,'String')); |
---|
976 | % last_i=str2num(get(handles.last_i,'String')); |
---|
977 | % incr=str2num(get(handles.incr_i,'String')); |
---|
978 | % num1=first_i:incr:last_i; |
---|
979 | % if isempty(num1) |
---|
980 | % set(handles.list_pair_civ1,'String',{''}); |
---|
981 | % return |
---|
982 | % end |
---|
983 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
984 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
985 | ref_j=0; |
---|
986 | else |
---|
987 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
988 | end |
---|
989 | time=get(handles.RootName,'UserData');%get the set of times |
---|
990 | if isempty(time) |
---|
991 | time=[0 1]; |
---|
992 | end |
---|
993 | %dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file |
---|
994 | dt_unit=1000;%default |
---|
995 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
996 | |
---|
997 | %eliminate the first pairs inconsistent with the position |
---|
998 | if isempty(displ_num) |
---|
999 | nbpair=0; |
---|
1000 | else |
---|
1001 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1002 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1003 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1004 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1005 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1006 | end |
---|
1007 | end |
---|
1008 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1009 | |
---|
1010 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
1011 | % be performed, while the result is needed for next steps. |
---|
1012 | displ_pair={''}; |
---|
1013 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
1014 | testpair=0; |
---|
1015 | if get(handles.CIV1,'Value')==0 % |
---|
1016 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
1017 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
1018 | set(handles.list_pair_civ1,'String',{}); |
---|
1019 | return |
---|
1020 | end |
---|
1021 | for ipair=1:nbpair |
---|
1022 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1023 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1024 | select(ipair)=exist(filename,'file')==2; |
---|
1025 | end |
---|
1026 | if ~exist('select','var') || isequal(select,zeros(size(1:nbpair))) |
---|
1027 | if isfield(browse,'incr_pair') |
---|
1028 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1029 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
1030 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1031 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
1032 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
1033 | select(1)=exist(filename,'file')==2; |
---|
1034 | testpair=1; |
---|
1035 | else |
---|
1036 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1037 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
1038 | else |
---|
1039 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
1040 | end |
---|
1041 | set(handles.list_pair_civ1,'String',{''}); |
---|
1042 | %COMPLETER CAS STEREO |
---|
1043 | return |
---|
1044 | end |
---|
1045 | end |
---|
1046 | end |
---|
1047 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1048 | if testpair |
---|
1049 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1050 | % elseif ~isequal(get(handles.root_txt,'String'),'dt(ms)=') |
---|
1051 | % for ipair=1:nbpair |
---|
1052 | % if select(ipair) |
---|
1053 | % if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1054 | % 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 |
---|
1055 | % displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1056 | % end |
---|
1057 | % else |
---|
1058 | % displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1059 | % end |
---|
1060 | % end |
---|
1061 | else |
---|
1062 | for ipair=1:nbpair |
---|
1063 | if select(ipair) |
---|
1064 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; |
---|
1065 | else |
---|
1066 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1067 | end |
---|
1068 | end |
---|
1069 | end |
---|
1070 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
1071 | if testpair |
---|
1072 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1073 | else |
---|
1074 | for ipair=1:nbpair |
---|
1075 | if select(ipair) |
---|
1076 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1077 | 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 |
---|
1078 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1079 | end |
---|
1080 | elseif testpair |
---|
1081 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
1082 | else |
---|
1083 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1084 | end |
---|
1085 | end |
---|
1086 | end |
---|
1087 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
1088 | for ipair=1:nbpair |
---|
1089 | if select(ipair) |
---|
1090 | 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 |
---|
1091 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1092 | ' :dt= ' num2str(dt*1000)]; |
---|
1093 | else |
---|
1094 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1095 | end |
---|
1096 | end |
---|
1097 | elseif isequal(mode,'displacement') |
---|
1098 | displ_pair={'Di=Dj=0'}; |
---|
1099 | end |
---|
1100 | set(handles.list_pair_civ1,'String',displ_pair'); |
---|
1101 | ichoice=min(find(select)); |
---|
1102 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
1103 | initial=get(handles.list_pair_civ1,'Value');%initial choice of pair |
---|
1104 | if initial>nbpair |
---|
1105 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1106 | end |
---|
1107 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
1108 | set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1109 | end |
---|
1110 | |
---|
1111 | %set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1112 | initial=get(handles.list_pair_civ2,'Value'); |
---|
1113 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
1114 | if ichoice <= length(displ_pair') |
---|
1115 | set(handles.list_pair_civ2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
1116 | else |
---|
1117 | set(handles.list_pair_civ2,'Value',1);% same pair proposed by default for civ2 |
---|
1118 | end |
---|
1119 | end |
---|
1120 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1121 | set(gcf,'Pointer','arrow') |
---|
1122 | |
---|
1123 | %------------------------------------------------------------------------ |
---|
1124 | % determine the menu for civ2 pairs depending on the existing netcdf file at the |
---|
1125 | %middle of the series set by first_i, incr, last_i |
---|
1126 | function find_netcpair_civ2(hObject, eventdata, handles) |
---|
1127 | %------------------------------------------------------------------------ |
---|
1128 | set(gcf,'Pointer','watch') |
---|
1129 | %nomenclature types |
---|
1130 | filebase=get(handles.RootName,'String'); |
---|
1131 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
1132 | browse=get(handles.browse_root,'UserData'); |
---|
1133 | compare_list=get(handles.compare,'String'); |
---|
1134 | val=get(handles.compare,'Value'); |
---|
1135 | compare=compare_list{val}; |
---|
1136 | if strcmp(compare,'displacement') |
---|
1137 | mode='displacement'; |
---|
1138 | else |
---|
1139 | mode_list=get(handles.mode,'String'); |
---|
1140 | mode_value=get(handles.mode,'Value'); |
---|
1141 | mode=mode_list{mode_value}; |
---|
1142 | end |
---|
1143 | |
---|
1144 | % nomenclature type of the .nc files |
---|
1145 | nom_type_ima='ima_num';%default |
---|
1146 | if isfield(browse,'nom_type_ima') |
---|
1147 | nom_type_ima=browse.nom_type_ima; |
---|
1148 | end |
---|
1149 | nom_type_nc='_i1-i2';%default |
---|
1150 | if isfield(browse,'nom_type_nc') |
---|
1151 | nom_type_nc=browse.nom_type_nc; |
---|
1152 | end |
---|
1153 | 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') |
---|
1154 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
1155 | elseif isequal(nom_type_ima,'none')|isequal(nom_type_nc,'none') |
---|
1156 | nom_type_nc='none'; |
---|
1157 | elseif isequal(nom_type_ima,'avi')|isequal(nom_type_ima,'_i')|isequal(nom_type_ima,'ima_num')|isequal(nom_type_nc,'_i1-i2') |
---|
1158 | nom_type_nc='_i1-i2'; |
---|
1159 | else |
---|
1160 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
1161 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
1162 | else |
---|
1163 | nom_type_nc='_i_j1-j2'; |
---|
1164 | end |
---|
1165 | end |
---|
1166 | browse.nom_type_nc=nom_type_nc; |
---|
1167 | set(handles.browse_root,'UserData',browse) |
---|
1168 | |
---|
1169 | %reads .nc subdirectory and image numbers from the interface |
---|
1170 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
1171 | subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
1172 | % first_i=str2num(get(handles.first_i,'String')); |
---|
1173 | % last_i=str2num(get(handles.last_i,'String')); |
---|
1174 | % incr=str2num(get(handles.incr_i,'String')); |
---|
1175 | % num1=first_i:incr:last_i; |
---|
1176 | % if isempty(num1) |
---|
1177 | % set(handles.list_pair_civ2,'Value',1); |
---|
1178 | % set(handles.list_pair_civ2,'String',{''}); |
---|
1179 | % return |
---|
1180 | % end |
---|
1181 | ref_i=str2num(get(handles.ref_i_civ2,'String')); |
---|
1182 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
1183 | ref_j=0; |
---|
1184 | else |
---|
1185 | ref_j=str2num(get(handles.ref_j_civ2,'String')); |
---|
1186 | end |
---|
1187 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
1188 | if isempty(time) |
---|
1189 | time=[0 1];%default |
---|
1190 | end |
---|
1191 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
1192 | dt_unit=1000; |
---|
1193 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1194 | |
---|
1195 | |
---|
1196 | %eliminate the first pairs inconsistent with the position |
---|
1197 | if isempty(displ_num) |
---|
1198 | nbpair=0; |
---|
1199 | else |
---|
1200 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1201 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
1202 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1203 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1204 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1205 | end |
---|
1206 | end |
---|
1207 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1208 | |
---|
1209 | %look for existing processed pairs involving the field at the middle of the series if civ1 will not |
---|
1210 | % be performed, while the result is needed for next steps. |
---|
1211 | displ_pair={''}; %default |
---|
1212 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
1213 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... |
---|
1214 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
1215 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
1216 | set(handles.list_pair_civ2,'Value',1); |
---|
1217 | set(handles.list_pair_civ2,'String',{''}); |
---|
1218 | return |
---|
1219 | end |
---|
1220 | for ipair=1:nbpair |
---|
1221 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1222 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1223 | select(ipair)=exist(filename,'file')==2; |
---|
1224 | end |
---|
1225 | if isequal(select,zeros(size(1:nbpair))) |
---|
1226 | if isfield(browse,'incr_pair') |
---|
1227 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1228 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
1229 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1230 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
1231 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
1232 | select(1)=exist(filename,'file')==2; |
---|
1233 | else |
---|
1234 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1235 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
1236 | else |
---|
1237 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
1238 | end |
---|
1239 | set(handles.list_pair_civ2,'Value',1); |
---|
1240 | set(handles.list_pair_civ2,'String',{''}); |
---|
1241 | return |
---|
1242 | end |
---|
1243 | end |
---|
1244 | end |
---|
1245 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
1246 | for ipair=1:nbpair |
---|
1247 | if select(ipair) |
---|
1248 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1249 | 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 |
---|
1250 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1251 | end |
---|
1252 | else |
---|
1253 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1254 | end |
---|
1255 | end |
---|
1256 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
1257 | for ipair=1:nbpair |
---|
1258 | if select(ipair) |
---|
1259 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1260 | 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 |
---|
1261 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1262 | end |
---|
1263 | else |
---|
1264 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1265 | end |
---|
1266 | end |
---|
1267 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
1268 | for ipair=1:nbpair |
---|
1269 | if select(ipair) |
---|
1270 | 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 |
---|
1271 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1272 | ' :dt= ' num2str(dt*1000)]; |
---|
1273 | else |
---|
1274 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1275 | end |
---|
1276 | end |
---|
1277 | elseif isequal(mode,'displacement') |
---|
1278 | displ_pair={'Di=Dj=0'}; |
---|
1279 | end |
---|
1280 | val=get(handles.list_pair_civ2,'Value'); |
---|
1281 | ichoice=min(find(select)); |
---|
1282 | if (isempty(ichoice) | ichoice < 1); ichoice=1; end; |
---|
1283 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
1284 | val=ichoice;% first valid pair proposed by default in the menu |
---|
1285 | end |
---|
1286 | if val>length(displ_pair') |
---|
1287 | set(handles.list_pair_civ2,'Value',1);% first valid pair proposed by default in the menu |
---|
1288 | else |
---|
1289 | set(handles.list_pair_civ2,'Value',val); |
---|
1290 | end |
---|
1291 | set(handles.list_pair_civ2,'String',displ_pair'); |
---|
1292 | set(gcf,'Pointer','arrow') |
---|
1293 | |
---|
1294 | %------------------------------------------------------------------------ |
---|
1295 | % determine the list of index pairs of processing file |
---|
1296 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
1297 | find_pair_indices(handles,mode) |
---|
1298 | %------------------------------------------------------------------------ |
---|
1299 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
1300 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
1301 | incr=str2double(get(handles.incr_i,'String'));% increment |
---|
1302 | num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair) |
---|
1303 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
1304 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
1305 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
1306 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
1307 | else |
---|
1308 | first_j=1; |
---|
1309 | last_j=1; |
---|
1310 | incr_j=1; |
---|
1311 | end |
---|
1312 | num_j=[first_j:incr_j:last_j];% list of j indices (reference values for each pair) |
---|
1313 | list_civ1=get(handles.list_pair_civ1,'String'); |
---|
1314 | index_civ1=get(handles.list_pair_civ1,'Value'); |
---|
1315 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
1316 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
1317 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
1318 | return |
---|
1319 | end |
---|
1320 | list_civ2=get(handles.list_pair_civ2,'String'); |
---|
1321 | index_civ2=get(handles.list_pair_civ2,'Value'); |
---|
1322 | if index_civ2>length(list_civ2) |
---|
1323 | list_civ2=list_civ1; |
---|
1324 | index_civ2=index_civ1; |
---|
1325 | end |
---|
1326 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
1327 | if isempty(first_i)||isempty(first_j), msgbox_uvmat('ERROR','first field number not defined'),... |
---|
1328 | return,end; |
---|
1329 | if isequal(last_i,[])|| isequal(last_j,[]),msgbox_uvmat('ERROR','last field number not defined'),... |
---|
1330 | return,end; |
---|
1331 | if isequal(incr,[])|| isequal(incr_j,[]),msgbox_uvmat('ERROR','increment in field number not defined'),... |
---|
1332 | return,end; |
---|
1333 | if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... |
---|
1334 | return,end; |
---|
1335 | if isequal (mode,'series(Di)') |
---|
1336 | %recognize the pair civ1 from the display |
---|
1337 | indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters |
---|
1338 | str_raw=str_civ1(indsel); |
---|
1339 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
1340 | d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
1341 | if indsepar==length(str_raw) |
---|
1342 | d2=str2double(str_civ1([indsel(indsepar)+1:end])); |
---|
1343 | else |
---|
1344 | d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
1345 | end |
---|
1346 | num1_civ1=num_i-d1;% set of first image numbers |
---|
1347 | num2_civ1=num_i+d2; |
---|
1348 | num_a_civ1=num_j; |
---|
1349 | num_b_civ1=num_j; |
---|
1350 | |
---|
1351 | %recognize the pair civ2 from the display |
---|
1352 | indsel=find((double(str_civ2)<48)|(double(str_civ2)>57));% character indices of non numerical characters |
---|
1353 | str_raw=str_civ2(indsel); |
---|
1354 | indsepar=find(str_raw=='|'); %character index of the separator |
---|
1355 | d1=str2num(str_civ2([indsel(indsepar-1)+1:indsel(indsepar)-1])); |
---|
1356 | if indsepar==length(str_raw) |
---|
1357 | d2=str2num(str_civ2([indsel(indsepar)+1:end])); |
---|
1358 | else |
---|
1359 | d2=str2num(str_civ2([indsel(indsepar)+1:indsel(indsepar+1)-1])); |
---|
1360 | end |
---|
1361 | if isempty(d1) |
---|
1362 | num1_civ2=num_i; |
---|
1363 | else |
---|
1364 | num1_civ2=num_i-d1;% set of first image numbers |
---|
1365 | end |
---|
1366 | if isempty(d2) |
---|
1367 | num2_civ2=num_i; |
---|
1368 | else |
---|
1369 | num2_civ2=num_i+d2; |
---|
1370 | end |
---|
1371 | num_a_civ2=num_j; |
---|
1372 | num_b_civ2=num_j; |
---|
1373 | |
---|
1374 | % adjust the first and last field number |
---|
1375 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
1376 | if isequal(lastfield,[]) |
---|
1377 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
1378 | else |
---|
1379 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
1380 | end |
---|
1381 | if length(indsel)>=1 |
---|
1382 | firstind=indsel(1); |
---|
1383 | lastind=indsel(end); |
---|
1384 | set(handles.first_i,'String',num2str(num_i(firstind)))%update the display of first and last fields |
---|
1385 | set(handles.last_i,'String',num2str(num_i(lastind))) |
---|
1386 | num_i=num_i(indsel); |
---|
1387 | num1_civ1=num1_civ1(indsel); |
---|
1388 | num1_civ2=num1_civ2(indsel); |
---|
1389 | num2_civ1=num2_civ1(indsel); |
---|
1390 | num2_civ2=num2_civ2(indsel); |
---|
1391 | end |
---|
1392 | elseif isequal (mode,'series(Dj)') |
---|
1393 | lastfield_j=str2num(get(handles.nb_field2,'String')); |
---|
1394 | num1_civ1=num_i;% set of first image numbers |
---|
1395 | num2_civ1=num_i; |
---|
1396 | num_a_civ1=num_j-floor(index_civ1/2)*ones(size(num_j)); |
---|
1397 | num_b_civ1=num_j+ceil(index_civ1/2)*ones(size(num_j)); |
---|
1398 | num1_civ2=num_i; |
---|
1399 | num2_civ2=num_i; |
---|
1400 | num_a_civ2=num_j-floor(index_civ2/2)*ones(size(num_j)); |
---|
1401 | num_b_civ2=num_j+ceil(index_civ2/2)*ones(size(num_j)); |
---|
1402 | % adjust the first and last field number |
---|
1403 | if isequal(lastfield_j,[]) |
---|
1404 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
1405 | else |
---|
1406 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
1407 | end |
---|
1408 | if length(indsel)>=1 |
---|
1409 | firstind=indsel(1); |
---|
1410 | lastind=indsel(end); |
---|
1411 | set(handles.first_j,'String',num2str(num_j(firstind)))%update the display of first and last fields |
---|
1412 | set(handles.last_j,'String',num2str(num_j(lastind))) |
---|
1413 | num_j=num_j(indsel); |
---|
1414 | num_a_civ1=num_a_civ1(indsel); |
---|
1415 | num_a_civ2=num_a_civ2(indsel); |
---|
1416 | num_b_civ1=num_b_civ1(indsel); |
---|
1417 | num_b_civ2=num_b_civ2(indsel); |
---|
1418 | end |
---|
1419 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
1420 | num1_civ1=num_i; |
---|
1421 | num1_civ2=num_i; |
---|
1422 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1423 | num2_civ1=num_i; |
---|
1424 | num_a_civ1=displ_num(1,index_civ1); |
---|
1425 | num_b_civ1=displ_num(2,index_civ1); |
---|
1426 | num2_civ2=num_i; |
---|
1427 | num_a_civ2=displ_num(1,index_civ2); |
---|
1428 | num_b_civ2=displ_num(2,index_civ2); |
---|
1429 | elseif isequal(mode,'displacement') |
---|
1430 | num1_civ1=num_i; |
---|
1431 | num2_civ1=num_i; |
---|
1432 | num_a_civ1=num_j; |
---|
1433 | num_b_civ1=num_j; |
---|
1434 | num1_civ2=num_i; |
---|
1435 | num2_civ2=num_i; |
---|
1436 | num_a_civ2=num_j; |
---|
1437 | num_b_civ2=num_j; |
---|
1438 | end |
---|
1439 | |
---|
1440 | |
---|
1441 | %------------------------------------------------------------------------ |
---|
1442 | % --- Executes on selection change in list_pair_civ1. |
---|
1443 | function list_pair_civ1_Callback(hObject, eventdata, handles) |
---|
1444 | %------------------------------------------------------------------------ |
---|
1445 | %reproduce by default the chosen pair in the civ2 menu |
---|
1446 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
1447 | index_pair=get(handles.list_pair_civ1,'Value'); |
---|
1448 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
1449 | num_a=displ_num(1,index_pair); |
---|
1450 | num_b=displ_num(2,index_pair); |
---|
1451 | list_pair2=get(handles.list_pair_civ2,'String');%get the menu of image pairs |
---|
1452 | if index_pair<=length(list_pair2) |
---|
1453 | set(handles.list_pair_civ2,'Value',index_pair); |
---|
1454 | end |
---|
1455 | |
---|
1456 | %update first_i and last_i according to the chosen image pairs |
---|
1457 | mode_list=get(handles.mode,'String'); |
---|
1458 | mode_value=get(handles.mode,'Value'); |
---|
1459 | mode=mode_list{mode_value}; |
---|
1460 | if isequal(mode,'series(Di)') |
---|
1461 | first_i=str2num(get(handles.first_i,'String')); |
---|
1462 | last_i=str2num(get(handles.last_i,'String')); |
---|
1463 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
1464 | num1=first_i:incr_i:last_i; |
---|
1465 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
1466 | if ~isequal(lastfield,[]) |
---|
1467 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1468 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
1469 | num1=num1(ind); |
---|
1470 | end |
---|
1471 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1472 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1473 | elseif isequal(mode,'series(Dj)') |
---|
1474 | first_j=str2num(get(handles.first_j,'String')); |
---|
1475 | last_j=str2num(get(handles.last_j,'String')); |
---|
1476 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
1477 | num_j=first_j:incr_j:last_j; |
---|
1478 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
1479 | if ~isequal(lastfield2,[]) |
---|
1480 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1481 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
1482 | num1=num_j(ind); |
---|
1483 | end |
---|
1484 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1485 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1486 | end |
---|
1487 | |
---|
1488 | %------------------------------------------------------------------------ |
---|
1489 | % --- Executes on selection change in list_pair_civ2. |
---|
1490 | function list_pair_civ2_Callback(hObject, eventdata, handles) |
---|
1491 | %------------------------------------------------------------------------ |
---|
1492 | index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu |
---|
1493 | |
---|
1494 | %update first_i and last_i according to the chosen image pairs |
---|
1495 | mode_list=get(handles.mode,'String'); |
---|
1496 | mode_value=get(handles.mode,'Value'); |
---|
1497 | mode=mode_list{mode_value}; |
---|
1498 | if isequal(mode,'series(Di)') |
---|
1499 | first_i=str2num(get(handles.first_i,'String')); |
---|
1500 | last_i=str2num(get(handles.last_i,'String')); |
---|
1501 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
1502 | num1=first_i:incr_i:last_i; |
---|
1503 | lastfield=str2num(get(handles.nb_field,'String')); |
---|
1504 | if ~isequal(lastfield,[]) |
---|
1505 | ind=find((num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1506 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield)); |
---|
1507 | num1=num1(ind); |
---|
1508 | end |
---|
1509 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1510 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1511 | elseif isequal(mode,'series(Dj)') |
---|
1512 | first_j=str2num(get(handles.first_j,'String')); |
---|
1513 | last_j=str2num(get(handles.last_j,'String')); |
---|
1514 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
1515 | num_j=first_j:incr_j:last_j; |
---|
1516 | lastfield2=str2num(get(handles.nb_field2,'String')); |
---|
1517 | if ~isequal(lastfield2,[]) |
---|
1518 | ind=find((num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1519 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2)); |
---|
1520 | num1=num_j(ind); |
---|
1521 | end |
---|
1522 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1523 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1524 | end |
---|
1525 | |
---|
1526 | %------------------------------------------------------------------------ |
---|
1527 | % --- Executes on button press in RUN. |
---|
1528 | |
---|
1529 | |
---|
1530 | |
---|
1531 | % compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
1532 | % %check the list of operations: |
---|
1533 | % operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
1534 | % run_flag=1; |
---|
1535 | % box_test(1)=get(handles.CIV1,'Value'); |
---|
1536 | % box_test(2)=get(handles.FIX1,'Value'); |
---|
1537 | % box_test(3)=get(handles.PATCH1,'Value'); |
---|
1538 | % box_test(4)=get(handles.CIV2,'Value'); |
---|
1539 | % box_test(5)=get(handles.FIX2,'Value'); |
---|
1540 | % box_test(6)=get(handles.PATCH2,'Value'); |
---|
1541 | % index=find(box_test==1); |
---|
1542 | % if isempty(index) |
---|
1543 | % msgbox_uvmat('ERROR','no selected operation') |
---|
1544 | % return |
---|
1545 | % end |
---|
1546 | % index_first=min(index); |
---|
1547 | % index_last=max(index); |
---|
1548 | % box_used=box_test([index_first : index_last]); |
---|
1549 | % [box_missing,ind_missing]=min(box_used); |
---|
1550 | % if isequal(box_missing,0) |
---|
1551 | % msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
1552 | % return |
---|
1553 | % end |
---|
1554 | % |
---|
1555 | % %root name |
---|
1556 | % filebase=get(handles.RootName,'String'); |
---|
1557 | % if isempty(filebase)||isequal(filebase,'') |
---|
1558 | % msgbox_uvmat('ERROR','no input files') |
---|
1559 | % return |
---|
1560 | % end |
---|
1561 | % %check mask if selecetd |
---|
1562 | % if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
1563 | % maskname=get(handles.mask_civ1,'String'); |
---|
1564 | % if ~exist(maskname,'file') |
---|
1565 | % get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
1566 | % end |
---|
1567 | % end |
---|
1568 | % if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
1569 | % maskname=get(handles.mask_fix1,'String'); |
---|
1570 | % if ~exist(maskname,'file') |
---|
1571 | % get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
1572 | % end |
---|
1573 | % end |
---|
1574 | % if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
1575 | % maskname=get(handles.mask_civ2,'String'); |
---|
1576 | % if ~exist(maskname,'file') |
---|
1577 | % get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
1578 | % end |
---|
1579 | % end |
---|
1580 | % if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
1581 | % maskname=get(handles.mask_fix2,'String'); |
---|
1582 | % if ~exist(maskname,'file') |
---|
1583 | % get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
1584 | % end |
---|
1585 | % end |
---|
1586 | % |
---|
1587 | % %read names of the .exe file |
---|
1588 | % if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1 |
---|
1589 | % path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
1590 | % path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
1591 | % %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names |
---|
1592 | % xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
1593 | % if exist(xmlfile,'file') |
---|
1594 | % t=xmltree(xmlfile); |
---|
1595 | % sparam=convert(t); |
---|
1596 | % end |
---|
1597 | % if isfield(sparam,'Civ1Bin') |
---|
1598 | % civ1Bin=sparam.Civ1Bin; |
---|
1599 | % if ~exist(civ1Bin,'file') |
---|
1600 | % civ1Bin=fullfile(path_UVMAT,civ1Bin); |
---|
1601 | % end |
---|
1602 | % end |
---|
1603 | % if isfield(sparam,'Civ2Bin') |
---|
1604 | % civ2Bin=sparam.Civ2Bin; |
---|
1605 | % if ~exist(civ2_exe,'file')%the binary is defined in /bin, default setting |
---|
1606 | % civ2_exe=fullfile(path_UVMAT,civ2_exe); |
---|
1607 | % end |
---|
1608 | % end |
---|
1609 | % if isfield(sparam,'Patch_exe') |
---|
1610 | % patch_exe=sparam.Patch_exe; |
---|
1611 | % if ~exist(patch_exe,'file')%the binary is defined in /bin, default setting |
---|
1612 | % patch_exe=fullfile(path_UVMAT,patch_exe); |
---|
1613 | % end |
---|
1614 | % end |
---|
1615 | % if isfield(sparam,'Stinterp_exe') |
---|
1616 | % stinterp_exe=sparam.Stinterp_exe; |
---|
1617 | % end |
---|
1618 | % if isfield(sparam,'SGE') |
---|
1619 | % sge=str2double(sparam.SGE); |
---|
1620 | % end |
---|
1621 | % if ~isunix % for windows system, check whether the Matlab working dir is a UBC name |
---|
1622 | % dircur=pwd; |
---|
1623 | % if ~isequal(dircur([2 3]),':\') |
---|
1624 | % msgbox_uvmat('ERROR','move to a Matlab current working directory with a Windows name, e.g. m:/...') |
---|
1625 | % return; |
---|
1626 | % end |
---|
1627 | % end |
---|
1628 | % end |
---|
1629 | % |
---|
1630 | % %initialize the waitbars |
---|
1631 | % set(handles.waitbar_1,'Position',[0.946 0.877 0.03 0.001]) |
---|
1632 | % set(handles.waitbar_patch1,'Position',[0.946 0.626 0.03 0.001]) |
---|
1633 | % set(handles.waitbar_civ2,'Position',[0.946 0.406 0.03 0.001]) |
---|
1634 | % set(handles.waitbar_patch2,'Position',[0.946 0.187 0.03 0.001]) |
---|
1635 | % set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1636 | % set(handles.RUN, 'Enable','Off') |
---|
1637 | % drawnow |
---|
1638 | % |
---|
1639 | % % get the list of file names and check the files |
---|
1640 | % display('checking the files...') |
---|
1641 | % [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]=... |
---|
1642 | % set_civ_filenames(handles,compare,box_test); |
---|
1643 | % nbfield=numel(num1_civ1); |
---|
1644 | % nbslice=size(num_a_civ1); |
---|
1645 | % |
---|
1646 | % if isempty(filecell) |
---|
1647 | % set(handles.RUN, 'Enable','On') |
---|
1648 | % set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1649 | % set(handles.BATCH, 'Enable','On') |
---|
1650 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
1651 | % return |
---|
1652 | % end |
---|
1653 | % display('files OK, processing...') |
---|
1654 | % nbfield=size(num1_civ1,2); |
---|
1655 | % nbslice=size(num1_civ1,1); |
---|
1656 | % |
---|
1657 | % %RUN CIV1 |
---|
1658 | % if box_test(1)==1 |
---|
1659 | % 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) |
---|
1660 | % if compare==3 |
---|
1661 | % 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) |
---|
1662 | % end |
---|
1663 | % end |
---|
1664 | % |
---|
1665 | % %RUN FIX1 |
---|
1666 | % if box_test(2)==1 |
---|
1667 | % filebase=get(handles.RootName,'String'); |
---|
1668 | % %names of the civ1 fields |
---|
1669 | % field1.vel_type='civ1'; |
---|
1670 | % field1.nb='nb_vectors'; |
---|
1671 | % % field1.X='vec_X'; |
---|
1672 | % % field1.Y='vec_Y'; |
---|
1673 | % % field1.U='vec_U'; |
---|
1674 | % % field1.V='vec_V'; |
---|
1675 | % field1.fixflag='vec_FixFlag'; |
---|
1676 | % flagindex(1)=get(handles.vec_Fmin2, 'Value'); |
---|
1677 | % flagindex(2)=get(handles.vec_F3, 'Value'); |
---|
1678 | % flagindex(3)=get(handles.vec_F2, 'Value'); |
---|
1679 | % thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
1680 | % thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
1681 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
1682 | % menu=get(handles.field_ref1,'String'); |
---|
1683 | % index=get(handles.field_ref1,'Value'); |
---|
1684 | % if isempty(menu) |
---|
1685 | % fieldchoice=''; |
---|
1686 | % else |
---|
1687 | % fieldchoice=menu{index}; |
---|
1688 | % end |
---|
1689 | % h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar |
---|
1690 | % test_mask=get(handles.get_mask_fix1,'Value'); |
---|
1691 | % if test_mask |
---|
1692 | % maskdispl=get(handles.mask_fix1,'String'); |
---|
1693 | % if exist(maskdispl,'file') |
---|
1694 | % test_mask=2; |
---|
1695 | % maskname=maskdispl; |
---|
1696 | % else |
---|
1697 | % maskbase=[get(handles.RootName,'String') '_' maskdispl]; % mask root name |
---|
1698 | % end |
---|
1699 | % end |
---|
1700 | % for ifile=1:nbfield |
---|
1701 | % waitbar(ifile/nbfield); %update the waitbar |
---|
1702 | % for j=1:nbslice |
---|
1703 | % if test_mask==0 |
---|
1704 | % maskname='noFile use default'; |
---|
1705 | % maskflag=0; |
---|
1706 | % elseif test_mask==1 |
---|
1707 | % nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
1708 | % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
1709 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair |
---|
1710 | % maskflag= exist(maskname,'file')==2; |
---|
1711 | % if ~maskflag; |
---|
1712 | % maskname='noFile use default'; |
---|
1713 | % end |
---|
1714 | % end |
---|
1715 | % if ~isempty(file_ref_fix1) |
---|
1716 | % file_ref=file_ref_fix1{ifile,j}; |
---|
1717 | % else |
---|
1718 | % file_ref=''; |
---|
1719 | % end |
---|
1720 | % error=RUN_FIX(filecell.nc.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
1721 | % thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
1722 | % |
---|
1723 | % if compare==3 &&(isequal(mode,'pair j1-j2') || isequal(mode,'series(Dj)') || isequal(mode,'series(Di)')) |
---|
1724 | % if test_mask==0 |
---|
1725 | % maskname='noFile use default'; |
---|
1726 | % maskflag=0; |
---|
1727 | % else |
---|
1728 | % maskbase=[get(handles.RootName2,'String') '_' maskdispl]; % mask root name |
---|
1729 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
1730 | % num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
1731 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1732 | % maskflag= exist(maskname,'file')==2; |
---|
1733 | % if ~maskflag; |
---|
1734 | % maskname='noFile use default'; |
---|
1735 | % end |
---|
1736 | % end |
---|
1737 | % error=RUN_FIX(filecell.ncA.civ1{ifile,j},field1,flagindex,1,thresh_vecC,maskflag,maskname,... |
---|
1738 | % thresh_vel,inf_sup,file_ref,fieldchoice); |
---|
1739 | % if ~isempty(error) |
---|
1740 | % msgbox_uvmat('ERROR',error) |
---|
1741 | % return |
---|
1742 | % end |
---|
1743 | % end |
---|
1744 | % end |
---|
1745 | % end |
---|
1746 | % close(h) |
---|
1747 | % end |
---|
1748 | % |
---|
1749 | % % RUN PATCH1 |
---|
1750 | % if box_test(3)==1 |
---|
1751 | % rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
1752 | % if isempty(rho_patch1) |
---|
1753 | % rho_patch1='1000'; |
---|
1754 | % set(handles.rho_patch1,'String','1') |
---|
1755 | % else |
---|
1756 | % rho_patch1=num2str(1000*rho_patch1); |
---|
1757 | % end |
---|
1758 | % nx_patch1=get(handles.nx_patch1,'String'); |
---|
1759 | % if isequal(str2num(nx_patch1),[]) |
---|
1760 | % nx_patch1='50' ;%default |
---|
1761 | % set(handles.nx_patch1,'String','50'); |
---|
1762 | % end |
---|
1763 | % ny_patch1=get(handles.ny_patch1,'String'); |
---|
1764 | % if isequal(str2num(ny_patch1),[]) |
---|
1765 | % ny_patch1='50' ;%default |
---|
1766 | % set(handles.ny_patch1,'String','50'); |
---|
1767 | % end |
---|
1768 | % subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
1769 | % thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
1770 | % test_interp=get(handles.test_interp,'Value'); |
---|
1771 | % icount=0; |
---|
1772 | % for ifile=1:nbfield |
---|
1773 | % for j=1:nbslice |
---|
1774 | % icount=icount+1; |
---|
1775 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
1776 | % set(handles.waitbar_patch1,'Position',[0.946 0.627-barlength 0.03 barlength]) |
---|
1777 | % drawnow |
---|
1778 | % if isequal(get(handles.test_stereo1,'Value'),0) |
---|
1779 | % cmd=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
1780 | % s=-1; |
---|
1781 | % if sge |
---|
1782 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1783 | % end |
---|
1784 | % if s~=0 |
---|
1785 | % display(['!' cmd]) |
---|
1786 | % eval(['!' cmd]); |
---|
1787 | % end |
---|
1788 | % |
---|
1789 | % %stereo case: |
---|
1790 | % elseif isequal(get(handles.test_stereo1,'Value'),1) |
---|
1791 | % if exist('stinterp_exe','var')%Prog Gauthier |
---|
1792 | % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},filecell.st{ifile,j},... |
---|
1793 | % nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
1794 | % display(['!' cmd]) |
---|
1795 | % eval(['!' cmd]); |
---|
1796 | % else |
---|
1797 | % RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
1798 | % str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']); |
---|
1799 | % end |
---|
1800 | % end |
---|
1801 | % if compare==3 && isequal(get(handles.test_stereo1,'Value'),0) |
---|
1802 | % cmd=RUN_PATCH(filecell.ncA.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
1803 | % s=-1; |
---|
1804 | % if sge |
---|
1805 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1806 | % end |
---|
1807 | % if s~=0 |
---|
1808 | % display(['!' cmd]) |
---|
1809 | % eval(['!' cmd]); |
---|
1810 | % end |
---|
1811 | % end |
---|
1812 | % end |
---|
1813 | % end |
---|
1814 | % end |
---|
1815 | % |
---|
1816 | % % CIV2 |
---|
1817 | % if box_test(4)==1 |
---|
1818 | % RUN_CIV2(handles,filecell.ima1.civ2,filecell.ima2.civ2,filecell.nc.civ1,filecell.nc.civ2,num1_civ2,num2_civ2,... |
---|
1819 | % num_a_civ2,num_b_civ2,nom_type_nc) |
---|
1820 | % end |
---|
1821 | % |
---|
1822 | % % FIX2 |
---|
1823 | % if box_test(5)==1 |
---|
1824 | % %names of the civ2 fields |
---|
1825 | % field2.vel_type='civ2'; |
---|
1826 | % field2.nb='nb_vectors2'; |
---|
1827 | % field2.X='vec2_X'; |
---|
1828 | % field2.Y='vec2_Y'; |
---|
1829 | % field2.U='vec2_U'; |
---|
1830 | % field2.V='vec2_V'; |
---|
1831 | % field2.fixflag='vec2_FixFlag'; |
---|
1832 | % flagindex(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
1833 | % flagindex(2)=get(handles.vec_F3_2, 'Value'); |
---|
1834 | % flagindex(3)=get(handles.vec_F4, 'Value'); |
---|
1835 | % thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
1836 | % thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
1837 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
1838 | % menu=get(handles.field_ref2,'String'); |
---|
1839 | % index=get(handles.field_ref2,'Value'); |
---|
1840 | % if isempty(menu) |
---|
1841 | % fieldchoice=''; |
---|
1842 | % else |
---|
1843 | % fieldchoice=menu{index}; |
---|
1844 | % end |
---|
1845 | % h = waitbar(0,['removing velocity vectors, fix2']);% display a wait bar |
---|
1846 | % test_mask=get(handles.get_mask_fix2,'Value'); |
---|
1847 | % if test_mask |
---|
1848 | % maskdispl=get(handles.mask_fix2,'String'); |
---|
1849 | % if exist(maskdispl,'file') |
---|
1850 | % test_mask=2; |
---|
1851 | % maskname=maskdispl; |
---|
1852 | % else |
---|
1853 | % maskbase=[get(handles.RootName,'String') '_' maskdispl]; % mask root name |
---|
1854 | % end |
---|
1855 | % end |
---|
1856 | % for ifile=1:nbfield |
---|
1857 | % waitbar(ifile/nbfield); %update the waitbar |
---|
1858 | % for j=1:nbslice |
---|
1859 | % if test_mask==0 |
---|
1860 | % maskname='noFile use default'; |
---|
1861 | % maskflag=0; |
---|
1862 | % elseif test_mask==1 |
---|
1863 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
1864 | % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
1865 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1866 | % maskflag= exist(maskname,'file')==2; |
---|
1867 | % if ~maskflag; |
---|
1868 | % maskname='noFile use default'; |
---|
1869 | % end |
---|
1870 | % end |
---|
1871 | % if ~isempty(file_ref_fix2) |
---|
1872 | % file_ref=file_ref_fix2{ifile,j}; |
---|
1873 | % else |
---|
1874 | % file_ref=''; |
---|
1875 | % end |
---|
1876 | % error=RUN_FIX(filecell.nc.civ2{ifile,j},field2,flagindex,2,thresh_vec2C,maskflag,maskname,... |
---|
1877 | % thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
1878 | % if ~isempty(error) |
---|
1879 | % msgbox_uvmat('ERROR',error) |
---|
1880 | % return |
---|
1881 | % end |
---|
1882 | % if compare==3 |
---|
1883 | % if test_mask==0 |
---|
1884 | % maskname='noFile use default'; |
---|
1885 | % maskflag=0; |
---|
1886 | % else |
---|
1887 | % maskbase=[get(handles.RootName2,'String') '_' maskdispl]; % mask root name |
---|
1888 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
1889 | % num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
1890 | % maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1891 | % maskflag= exist(maskname,'file')==2; |
---|
1892 | % if ~maskflag; |
---|
1893 | % maskname='noFile use default'; |
---|
1894 | % end |
---|
1895 | % end |
---|
1896 | % error=RUN_FIX(filecell.ncA.civ2{ifile,j},field2,flagindex,1,thresh_vec2C,maskflag,maskname,... |
---|
1897 | % thresh_vel2,inf_sup,file_ref,fieldchoice); |
---|
1898 | % if ~isempty(error) |
---|
1899 | % msgbox_uvmat('ERROR',error) |
---|
1900 | % return |
---|
1901 | % end |
---|
1902 | % end |
---|
1903 | % end |
---|
1904 | % end |
---|
1905 | % close(h) |
---|
1906 | % end |
---|
1907 | % |
---|
1908 | % %PATCH 2 |
---|
1909 | % if box_test(6)==1 |
---|
1910 | % rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
1911 | % if isempty(rho_patch2) |
---|
1912 | % rho_patch2='1000'; |
---|
1913 | % set(handles.rho_patch2,'String','1') |
---|
1914 | % else |
---|
1915 | % rho_patch2=num2str(1000*rho_patch2); |
---|
1916 | % end |
---|
1917 | % nx_patch2=get(handles.nx_patch2,'String'); |
---|
1918 | % ny_patch2=get(handles.ny_patch2,'String'); |
---|
1919 | % thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
1920 | % if isequal(str2num(nx_patch2),[]) |
---|
1921 | % nx_patch2='50' ;%default |
---|
1922 | % set(handles.nx_patch2,'String','50'); |
---|
1923 | % end |
---|
1924 | % if isequal(str2num(ny_patch2),[]) |
---|
1925 | % ny_patch2='50' ;%default |
---|
1926 | % set(handles.ny_patch2,'String','50'); |
---|
1927 | % end |
---|
1928 | % subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
1929 | % icount=0; |
---|
1930 | % for ifile=1:nbfield |
---|
1931 | % for j=1:nbslice |
---|
1932 | % icount=icount+1; |
---|
1933 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
1934 | % set(handles.waitbar_patch2,'Position',[0.946 0.188-barlength 0.03 barlength]) |
---|
1935 | % drawnow |
---|
1936 | % if compare~=3 | isequal(get(handles.test_stereo2,'Value'),0) |
---|
1937 | % cmd=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
1938 | % s=-1; |
---|
1939 | % if sge |
---|
1940 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1941 | % end |
---|
1942 | % if s~=0 |
---|
1943 | % display(['!' cmd]) |
---|
1944 | % eval(['!' cmd]); |
---|
1945 | % end |
---|
1946 | % elseif compare==3 && isequal(get(handles.test_stereo2,'Value'),1) |
---|
1947 | % if exist('stinterp_exe','var')%Prog Gauthier |
---|
1948 | % cmd=RUN_STINTERP(stinterp_exe,filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},filecell.st{ifile,j},... |
---|
1949 | % nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,[filebase_A '.xml'],[filebase_B '.xml']); |
---|
1950 | % display(['!' cmd]) |
---|
1951 | % eval(['!' cmd]) |
---|
1952 | % else |
---|
1953 | % RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
1954 | % str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
1955 | % end |
---|
1956 | % end |
---|
1957 | % if compare==3 && isequal(get(handles.test_stereo2,'Value'),0) |
---|
1958 | % cmd=RUN_PATCH(filecell.ncA.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,1,0); |
---|
1959 | % s=-1; |
---|
1960 | % if sge |
---|
1961 | % [s,w]=unix(['qrsh -q -fast.q ' cmd]); |
---|
1962 | % end |
---|
1963 | % if s~=0 |
---|
1964 | % display(['!' cmd]) |
---|
1965 | % eval(['!' cmd]); |
---|
1966 | % end |
---|
1967 | % end |
---|
1968 | % end |
---|
1969 | % end |
---|
1970 | % end |
---|
1971 | % |
---|
1972 | % set(handles.RUN, 'Enable','On') |
---|
1973 | % set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1974 | % |
---|
1975 | % %save the current interface setting as figure namefig, append .0 to the name if it already exists |
---|
1976 | % if isfield(filecell,'st') |
---|
1977 | % fileresu=filecell.st{1,1}; |
---|
1978 | % elseif isfield(filecell,'nc') |
---|
1979 | % if isfield(filecell.nc,'civ2') |
---|
1980 | % fileresu=filecell.nc.civ2{1,1}; |
---|
1981 | % else |
---|
1982 | % fileresu=filecell.nc.civ1{1,1}; |
---|
1983 | % end |
---|
1984 | % end |
---|
1985 | % [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
1986 | % namedoc=fullfile(RootPath,subdir,RootFile); |
---|
1987 | % detect=1; |
---|
1988 | % while detect==1 |
---|
1989 | % namefigfull=[namedoc '.fig']; |
---|
1990 | % hh=dir(namefigfull); |
---|
1991 | % if ~isempty(hh) |
---|
1992 | % detect=1; |
---|
1993 | % namedoc=[namedoc '.0']; |
---|
1994 | % else |
---|
1995 | % detect=0; |
---|
1996 | % end |
---|
1997 | % end |
---|
1998 | % saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
1999 | |
---|
2000 | function RUN_Callback(hObject, eventdata, handles) |
---|
2001 | %------------------------------------------------------------------------ |
---|
2002 | % global civ1_exe civ2_exe patch_exe patch_new_exe sge |
---|
2003 | |
---|
2004 | batch=0; |
---|
2005 | launch_jobs(hObject, eventdata, handles,batch); |
---|
2006 | |
---|
2007 | |
---|
2008 | %------------------------------------------------------------------------ |
---|
2009 | % --- Executes on button press in BATCH: remote processing |
---|
2010 | function BATCH_Callback(hObject, eventdata, handles) |
---|
2011 | %------------------------------------------------------------------------ |
---|
2012 | %global civ1_exe civ2_exe patch_exe patch_new_exe fix_exe todo_path sge Civ_exe % probabely to remove |
---|
2013 | batch=1; |
---|
2014 | launch_jobs(hObject, eventdata, handles, batch) |
---|
2015 | |
---|
2016 | %------------------------------------------------------------------------ |
---|
2017 | % --- Executes on button press in BATCH: remote processing |
---|
2018 | function launch_jobs(hObject, eventdata, handles, batch) |
---|
2019 | %----------------------------------------------------------------------- |
---|
2020 | % global civ2Bin patchBin patch_newBin fixBin CivBin % probabely to remove |
---|
2021 | |
---|
2022 | compare=get(handles.compare,'Value');%test for usual PIV (compare=1) or displacement (=2) or stereo PIV (=3) |
---|
2023 | |
---|
2024 | %check the list of operations: |
---|
2025 | operations={'CIV1','FIX1','PATCH1','CIV2','FIX2','PATCH2'}; |
---|
2026 | run_flag=1; |
---|
2027 | box_test(1)=get(handles.CIV1,'Value'); |
---|
2028 | box_test(2)=get(handles.FIX1,'Value'); |
---|
2029 | box_test(3)=get(handles.PATCH1,'Value'); |
---|
2030 | box_test(4)=get(handles.CIV2,'Value'); |
---|
2031 | box_test(5)=get(handles.FIX2,'Value'); |
---|
2032 | box_test(6)=get(handles.PATCH2,'Value'); |
---|
2033 | index=find(box_test==1); |
---|
2034 | if isempty(index) |
---|
2035 | msgbox_uvmat('ERROR','no selected operation') |
---|
2036 | return |
---|
2037 | end |
---|
2038 | index_first=min(index); |
---|
2039 | index_last=max(index); |
---|
2040 | box_used=box_test([index_first : index_last]); |
---|
2041 | [box_missing,ind_missing]=min(box_used); |
---|
2042 | if isequal(box_missing,0) |
---|
2043 | msgbox_uvmat('ERROR',['missing' cell2mat(operations(ind_missing))]); |
---|
2044 | return |
---|
2045 | end |
---|
2046 | |
---|
2047 | %root name |
---|
2048 | filebase=get(handles.RootName,'String'); |
---|
2049 | if isempty(filebase)||isequal(filebase,'') |
---|
2050 | msgbox_uvmat('ERROR','no input files') |
---|
2051 | return |
---|
2052 | end |
---|
2053 | |
---|
2054 | %check mask if selecetd |
---|
2055 | if isequal(get(handles.get_mask_civ1,'Value'),1) |
---|
2056 | maskname=get(handles.mask_civ1,'String'); |
---|
2057 | if ~exist(maskname,'file') |
---|
2058 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
2059 | end |
---|
2060 | end |
---|
2061 | if isequal(get(handles.get_mask_fix1,'Value'),1) |
---|
2062 | maskname=get(handles.mask_fix1,'String'); |
---|
2063 | if ~exist(maskname,'file') |
---|
2064 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
2065 | end |
---|
2066 | end |
---|
2067 | if isequal(get(handles.get_mask_civ2,'Value'),1) |
---|
2068 | maskname=get(handles.mask_civ2,'String'); |
---|
2069 | if ~exist(maskname,'file') |
---|
2070 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
2071 | end |
---|
2072 | end |
---|
2073 | if isequal(get(handles.get_mask_fix2,'Value'),1) |
---|
2074 | maskname=get(handles.mask_fix2,'String'); |
---|
2075 | if ~exist(maskname,'file') |
---|
2076 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
2077 | end |
---|
2078 | end |
---|
2079 | |
---|
2080 | %read names of the .exe file |
---|
2081 | path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
2082 | path_UVMAT=fileparts(path_uvmat); %path to UVMAT |
---|
2083 | xmlfile=fullfile(path_UVMAT,'PARAM.xml'); |
---|
2084 | if exist(xmlfile,'file') |
---|
2085 | t=xmltree(xmlfile); |
---|
2086 | s=convert(t); |
---|
2087 | end |
---|
2088 | % else |
---|
2089 | % xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml'); |
---|
2090 | % if exist(xmlfile,'file') |
---|
2091 | % t=xmltree(xmlfile); |
---|
2092 | % sparam=convert(t); |
---|
2093 | % end |
---|
2094 | % end |
---|
2095 | % batch=0; |
---|
2096 | if batch |
---|
2097 | if isfield(s,'BatchParam') |
---|
2098 | sparam=s.BatchParam; |
---|
2099 | if ~ismember(sparam.BatchMode,{'sge'}) |
---|
2100 | msgbox_uvmat('ERROR',['batch mode ' sparam.BatchMode ' not supported by UVMAT']) |
---|
2101 | end |
---|
2102 | else |
---|
2103 | msgbox_uvmat('ERROR','no batch mode defined in PARAM.xml') |
---|
2104 | return |
---|
2105 | end |
---|
2106 | else |
---|
2107 | if isfield(s,'RunParam') |
---|
2108 | sparam=s.RunParam; |
---|
2109 | else |
---|
2110 | msgbox_uvmat('ERROR','no civ binaries defined in PARAM.xml') |
---|
2111 | return |
---|
2112 | end |
---|
2113 | end |
---|
2114 | if isfield(sparam,'CivBin') |
---|
2115 | CivBin=sparam.CivBin; |
---|
2116 | end |
---|
2117 | if isfield(sparam,'Civ1Bin') |
---|
2118 | civ1Bin=sparam.Civ1Bin; |
---|
2119 | end |
---|
2120 | if isfield(sparam,'Civ2Bin') |
---|
2121 | civ2Bin=sparam.Civ2Bin; |
---|
2122 | end |
---|
2123 | if isfield(sparam,'PatchBin') |
---|
2124 | patchBin=sparam.PatchBin; |
---|
2125 | end |
---|
2126 | if isfield(sparam,'PatchNewBin') |
---|
2127 | patch_newBin=sparam.PatchNewBin; |
---|
2128 | end |
---|
2129 | if isfield(sparam,'FixBin') |
---|
2130 | fixBin=sparam.FixBin; |
---|
2131 | end |
---|
2132 | % if isfield(sparam,'Todo_path') |
---|
2133 | % todo_path=sparam.Todo_path; |
---|
2134 | % end |
---|
2135 | if batch |
---|
2136 | if isfield(sparam,'BatchMode') |
---|
2137 | batch_mode=sparam.BatchMode; |
---|
2138 | end |
---|
2139 | else |
---|
2140 | MaxCivProcesses=50; |
---|
2141 | if isfield(sparam,'MaxCivProcesses') |
---|
2142 | MaxCivProcesses=str2double(sparam.MaxCivProcesses); |
---|
2143 | end |
---|
2144 | end |
---|
2145 | |
---|
2146 | %initialize the waitbars |
---|
2147 | set(handles.waitbar_1,'Position',[0.946 0.876 0.03 0.001]) |
---|
2148 | set(handles.waitbar_patch1,'Position',[0.946 0.439 0.03 0.001]) |
---|
2149 | set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001]) |
---|
2150 | set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001]) |
---|
2151 | set(handles.BATCH, 'Enable','Off') |
---|
2152 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
2153 | drawnow |
---|
2154 | %get the filename root, nomenclature and numbers |
---|
2155 | |
---|
2156 | % for Windows system find the UBC path name if needed |
---|
2157 | if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\') |
---|
2158 | cur_dir=pwd; |
---|
2159 | if ~isequal(cur_dir(2:3),':\') |
---|
2160 | cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: |
---|
2161 | end |
---|
2162 | [ss,ww]=dos(['net use ' filebase(1:2)]); |
---|
2163 | if isequal(ss,0) |
---|
2164 | rankpath=findstr(ww,'\\'); |
---|
2165 | if ~isempty(rankpath) |
---|
2166 | wwrest=ww(rankpath:end); |
---|
2167 | rankend=min(find(double(wwrest)==10))-1; |
---|
2168 | filebase=[wwrest(1:rankend) filebase(3:end)]; |
---|
2169 | set(handles.RootName,'String',filebase); |
---|
2170 | end |
---|
2171 | else |
---|
2172 | msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed'); |
---|
2173 | set(handles.BATCH, 'Enable','On') |
---|
2174 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2175 | return |
---|
2176 | end |
---|
2177 | end |
---|
2178 | |
---|
2179 | % set the list of files and check them |
---|
2180 | display('checking the files...') |
---|
2181 | [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]=... |
---|
2182 | set_civ_filenames(handles,compare,box_test); |
---|
2183 | |
---|
2184 | %choice of batch priority |
---|
2185 | ind_answer=2; |
---|
2186 | if batch |
---|
2187 | [s,w]=unix('qstat -q civ.q|grep job_| wc -l'); %check the waiting list (command unix) |
---|
2188 | if isequal(s,0) |
---|
2189 | w(end)=[]; |
---|
2190 | str_displ={[w ' jobs in the waiting list'];'Select a priority:'}; |
---|
2191 | str={'urgent';'normal';'low'}; |
---|
2192 | [ind_answer,v] = listdlg('PromptString',str_displ,... |
---|
2193 | 'SelectionMode','single',... |
---|
2194 | 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); |
---|
2195 | if isequal(v,0) % to handle Cancel button and figure close, |
---|
2196 | return % a better way should be create |
---|
2197 | end |
---|
2198 | else |
---|
2199 | msgbox_uvmat('ERROR','batch system not available') |
---|
2200 | return |
---|
2201 | end |
---|
2202 | else |
---|
2203 | if isunix |
---|
2204 | [s,w]=unix('ps faux |grep civ|wc -l'); |
---|
2205 | w(end)=[]; |
---|
2206 | if str2num(w)+numel(filecell)> MaxCivProcesses |
---|
2207 | msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'}) |
---|
2208 | return |
---|
2209 | end |
---|
2210 | end |
---|
2211 | end |
---|
2212 | |
---|
2213 | display('files OK, processing...') |
---|
2214 | nbfield=numel(num1_civ1); |
---|
2215 | nbslice=numel(num_a_civ1); |
---|
2216 | |
---|
2217 | %GET PARAMETERS: |
---|
2218 | %get civ parameters |
---|
2219 | if box_test(1)==1 |
---|
2220 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1,1}); |
---|
2221 | end |
---|
2222 | |
---|
2223 | %get fix1 parameters |
---|
2224 | if box_test(2)==1 |
---|
2225 | flagindex1(1)=get(handles.vec_Fmin2, 'Value'); |
---|
2226 | flagindex1(2)=get(handles.vec_F3, 'Value'); |
---|
2227 | flagindex1(3)=get(handles.vec_F2, 'Value'); |
---|
2228 | thresh_vecC1=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C |
---|
2229 | thresh_vel1=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus |
---|
2230 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
2231 | nbslice_mask=get(handles.mask_fix1,'UserData'); % get the number of slices (= number of masks) |
---|
2232 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX |
---|
2233 | % inf_sup=get(handles.inf_sup1,'Value'); |
---|
2234 | % fileref=get(handles.ref_fix1,'String'); |
---|
2235 | % refpath=get(handles.ref_fix1,'UserData'); |
---|
2236 | % fileref=fullfile(refpath,fileref); |
---|
2237 | menu=get(handles.field_ref1,'String'); |
---|
2238 | index=get(handles.field_ref1,'Value'); |
---|
2239 | if isempty(menu) |
---|
2240 | fieldchoice=''; |
---|
2241 | else |
---|
2242 | fieldchoice=menu{index}; |
---|
2243 | msgbox_uvmat('WARNING','reference field is not used presently with batch, use RUN option') |
---|
2244 | end |
---|
2245 | end |
---|
2246 | |
---|
2247 | %get patch1 parameters |
---|
2248 | if box_test(3)==1 |
---|
2249 | rho_patch1=str2num(get(handles.rho_patch1,'String')); |
---|
2250 | if isempty(rho_patch1) |
---|
2251 | rho_patch1='1000'; |
---|
2252 | set(handles.rho_patch1,'String','1') |
---|
2253 | else |
---|
2254 | rho_patch1=num2str(1000*rho_patch1); |
---|
2255 | end |
---|
2256 | nx_patch1=get(handles.nx_patch1,'String'); |
---|
2257 | ny_patch1=get(handles.ny_patch1,'String'); |
---|
2258 | if isequal(str2num(nx_patch1),[]) |
---|
2259 | nx_patch1='50' ;%default |
---|
2260 | set(handles.nx_patch1,'String','50'); |
---|
2261 | end |
---|
2262 | if isequal(str2num(ny_patch1),[]) |
---|
2263 | ny_patch1='50' ;%default |
---|
2264 | set(handles.ny_patch1,'String','50'); |
---|
2265 | end |
---|
2266 | subdomain_patch1=get(handles.subdomain_patch1,'String'); |
---|
2267 | thresh_patch1=get(handles.thresh_patch1,'String'); |
---|
2268 | test_interp=get(handles.test_interp,'Value'); |
---|
2269 | end |
---|
2270 | |
---|
2271 | %get civ2 parameters |
---|
2272 | if box_test(4)==1 |
---|
2273 | par_civ2=read_param_civ2(handles,cell2mat(filecell.ima1.civ2(1,1))); |
---|
2274 | end |
---|
2275 | |
---|
2276 | %get fix2 parameters |
---|
2277 | if box_test(5)==1 |
---|
2278 | flagindex2(1)=get(handles.vec_Fmin2_2, 'Value'); |
---|
2279 | flagindex2(2)=get(handles.vec_F3_2, 'Value'); |
---|
2280 | flagindex2(3)=get(handles.vec_F4, 'Value'); |
---|
2281 | thresh_vec2C=str2num(get(handles.thresh_vec2C,'String'));%threshold on image correlation vec_C |
---|
2282 | thresh_vel2=str2num(get(handles.thresh_vel2,'String'));%threshold on velocity modulus |
---|
2283 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
2284 | nbslice_mask=get(handles.mask_fix2,'UserData'); % get the number of slices (= number of masks) |
---|
2285 | %%%%%%%%%%%%%COMPLETER LE PROGRAMME FIX AVEC REF FILE ET OPTION inf_sup=2 |
---|
2286 | % inf_sup=get(handles.inf_sup2,'Value'); |
---|
2287 | % ref=get(handles.ref_fix2,'UserData'); |
---|
2288 | |
---|
2289 | %%%%%%%%%%%%%%%%%%% |
---|
2290 | end |
---|
2291 | |
---|
2292 | |
---|
2293 | %get patch2 parameters |
---|
2294 | if box_test(6)==1 |
---|
2295 | rho_patch2=str2num(get(handles.rho_patch2,'String')); |
---|
2296 | if isempty(rho_patch2) |
---|
2297 | rho_patch2='1000'; |
---|
2298 | set(handles.rho_patch2,'String','1') |
---|
2299 | else |
---|
2300 | rho_patch2=num2str(1000*rho_patch2); |
---|
2301 | end |
---|
2302 | nx_patch2=get(handles.nx_patch2,'String'); |
---|
2303 | ny_patch2=get(handles.ny_patch2,'String'); |
---|
2304 | if isequal(str2num(nx_patch2),[]) |
---|
2305 | nx_patch2='50' ;%default |
---|
2306 | set(handles.nx_patch2,'String','50'); |
---|
2307 | end |
---|
2308 | if isequal(str2num(ny_patch2),[]) |
---|
2309 | ny_patch2='50' ;%default |
---|
2310 | set(handles.ny_patch2,'String','50'); |
---|
2311 | end |
---|
2312 | subdomain_patch2=get(handles.subdomain_patch2,'String'); |
---|
2313 | thresh_patch2=get(handles.thresh_patch2,'String'); |
---|
2314 | test_interp=get(handles.test_interp,'Value'); |
---|
2315 | end |
---|
2316 | |
---|
2317 | % if ~sge |
---|
2318 | % |
---|
2319 | % %OPEN THE WAIT LIST FOR BATCH PROCESSES |
---|
2320 | % name_lock=fullfile(todo_path,'lock'); %lock file |
---|
2321 | % iwait=0; |
---|
2322 | % while(exist(name_lock) & iwait<15) |
---|
2323 | % pause(1); %wait 1 second |
---|
2324 | % iwait=iwait+1; |
---|
2325 | % end |
---|
2326 | % if iwait==15 |
---|
2327 | % msgbox_uvmat('ERROR',['I''m tired to wait for the lock file, please delete it then click again on BATCH' name_lock ]) |
---|
2328 | % set(handles.BATCH, 'Enable','On') |
---|
2329 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2330 | % return |
---|
2331 | % end |
---|
2332 | % p0=fopen(name_lock,'w'); %create the file name_lock: prevents other users to interfere |
---|
2333 | % name_todo=fullfile(todo_path,'TODO.txt'); |
---|
2334 | % p1=fopen(name_todo,'a'); |
---|
2335 | % if (p1<0) |
---|
2336 | % msgbox_uvmat('ERROR',['error in opening ' name_todo]) |
---|
2337 | % set(handles.BATCH, 'Enable','On') |
---|
2338 | % set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2339 | % return; |
---|
2340 | % end |
---|
2341 | % end |
---|
2342 | |
---|
2343 | %MAIN LOOP |
---|
2344 | % for ifile=1:nbfield |
---|
2345 | p1text=[];%initiate command text |
---|
2346 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
2347 | civAll=get(handles.Experimental,'Value'); % Boolean for new civ excution method |
---|
2348 | for ifile=1:nbfield |
---|
2349 | for j=1:nbslice |
---|
2350 | i_cmd=0; |
---|
2351 | cmd=''; |
---|
2352 | if batch |
---|
2353 | %fid=fopen([filename '.cmx'],'w') |
---|
2354 | cmd='#!/bin/bash'; |
---|
2355 | cmd=[cmd '\n' '#$ -cwd']; |
---|
2356 | cmd=[cmd '\n' 'hostname && date']; |
---|
2357 | end |
---|
2358 | if civAll |
---|
2359 | civAllxml=xmltree;% xml contents, all parameters |
---|
2360 | civAllCmd=[]; |
---|
2361 | civAllxml=set(civAllxml,1,'name','CivDoc'); |
---|
2362 | end |
---|
2363 | % filecell.nc.civ1 |
---|
2364 | filename_cmx=filecell.nc.civ1{ifile,j}%output netcdf file |
---|
2365 | filename_cmx(end-1:end)='cm';%name of cmx file |
---|
2366 | filename_cmx=[filename_cmx 'x']; |
---|
2367 | |
---|
2368 | %CIV1 |
---|
2369 | if box_test(1)==1 |
---|
2370 | par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
2371 | % par_civ1.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
2372 | par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
2373 | % par_civ1.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
2374 | |
---|
2375 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
2376 | par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
2377 | par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
2378 | par_civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
2379 | par_civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
2380 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
2381 | if test_mask==0 |
---|
2382 | par_civ1.maskname='noFile use default'; |
---|
2383 | par_civ1.maskflag='n'; |
---|
2384 | else |
---|
2385 | maskdispl=get(handles.mask_civ1,'String'); |
---|
2386 | if exist(maskdispl,'file') |
---|
2387 | par_civ1.maskname=maskdispl; |
---|
2388 | par_civ1.maskflag='y'; |
---|
2389 | else |
---|
2390 | maskbase=[filebase '_' maskdispl]; % |
---|
2391 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2392 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
2393 | par_civ1.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2394 | if exist(par_civ1.maskname,'file') |
---|
2395 | par_civ1.maskflag='y'; |
---|
2396 | else |
---|
2397 | par_civ1.maskname='noFile use default'; |
---|
2398 | par_civ1.maskflag='n'; |
---|
2399 | end |
---|
2400 | end |
---|
2401 | end |
---|
2402 | |
---|
2403 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
2404 | if test_grid |
---|
2405 | par_civ1.gridflag='y'; |
---|
2406 | gridname=get(handles.grid_civ1,'String'); |
---|
2407 | if isequal(gridname(end-3:end),'grid') |
---|
2408 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2409 | if ~isempty(nbslice_grid) |
---|
2410 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
2411 | par_civ1.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2412 | if ~exist(par_civ1.gridname,'file') |
---|
2413 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
2414 | end |
---|
2415 | elseif exist(gridname,'file') |
---|
2416 | par_civ1.gridname=gridname; |
---|
2417 | else |
---|
2418 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
2419 | end |
---|
2420 | end |
---|
2421 | else |
---|
2422 | par_civ1.gridname='noFile use default'; |
---|
2423 | par_civ1.gridflag='n'; |
---|
2424 | end |
---|
2425 | % |
---|
2426 | i_cmd=i_cmd+1; |
---|
2427 | if isequal(civAll,0) |
---|
2428 | cmd=[cmd '\n' BATCH_CIV1(filename_cmx(1:end-4),namelog,par_civ1,handles,sparam)]; |
---|
2429 | else |
---|
2430 | civAllCmd=[civAllCmd ' civ1 ']; |
---|
2431 | str=BATCH_CIV1_Unified(filename_cmx([1:end-4]),namelog,par_civ1); |
---|
2432 | fieldnames=fields(str); |
---|
2433 | [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1'); |
---|
2434 | for ilist=1:length(fieldnames) |
---|
2435 | val=eval(['str.' fieldnames{ilist}]); |
---|
2436 | if ischar(val) |
---|
2437 | [civAllxml,uid_t]=add(civAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
2438 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2439 | end |
---|
2440 | end |
---|
2441 | end |
---|
2442 | end |
---|
2443 | |
---|
2444 | % FIX1 |
---|
2445 | if box_test(2)==1 |
---|
2446 | test_mask=get(handles.get_mask_fix1,'Value'); |
---|
2447 | if test_mask==0 |
---|
2448 | maskname=''; |
---|
2449 | else |
---|
2450 | maskdispl=get(handles.mask_fix1,'String'); |
---|
2451 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2452 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
2453 | maskbase=[filebase '_' maskdispl]; |
---|
2454 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2455 | end |
---|
2456 | if isequal(civAll,0) |
---|
2457 | cmd_FIX=[fixBin ' -f ' filecell.nc.civ1{ifile,j} ' -fi1 ' num2str(flagindex1(1)) ... |
---|
2458 | ' -fi2 ' num2str(flagindex1(2)) ' -fi3 ' num2str(flagindex1(3)) ... |
---|
2459 | ' -threshC ' num2str(thresh_vecC1) ' -threshV ' num2str(thresh_vel1) ' -maskName ' maskname]; |
---|
2460 | cmd=[cmd '\n' cmd_FIX]; |
---|
2461 | else |
---|
2462 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
2463 | fix1.fi1=num2str(flagindex1(1)); |
---|
2464 | fix1.fi2=num2str(flagindex1(2)); |
---|
2465 | fix1.fi3=num2str(flagindex1(3)); |
---|
2466 | fix1.threshC=num2str(thresh_vecC1); |
---|
2467 | fix1.threshV=num2str(thresh_vel1); |
---|
2468 | fieldnames=fields(fix1); |
---|
2469 | [civAllxml,uid_fix1]=add(civAllxml,1,'element','fix1'); |
---|
2470 | for ilist=1:length(fieldnames) |
---|
2471 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
2472 | if ischar(val) |
---|
2473 | [civAllxml,uid_t]=add(civAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
2474 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2475 | end |
---|
2476 | end |
---|
2477 | civAllCmd=[civAllCmd ' fix1 ']; |
---|
2478 | end |
---|
2479 | end |
---|
2480 | |
---|
2481 | %PATCH1 |
---|
2482 | if box_test(3)==1 |
---|
2483 | if isequal(civAll,0) |
---|
2484 | cmd_PATCH=RUN_PATCH(filecell.nc.civ1{ifile,j},nx_patch1,ny_patch1,rho_patch1,subdomain_patch1,thresh_patch1,test_interp); |
---|
2485 | cmd=[cmd '\n' cmd_PATCH]; |
---|
2486 | else |
---|
2487 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
2488 | patch1.nopt=subdomain_patch1; |
---|
2489 | patch1.maxdiff=thresh_patch1; |
---|
2490 | patch1.ro=rho_patch1; |
---|
2491 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
2492 | if test_grid |
---|
2493 | patch1.gridflag='y'; |
---|
2494 | gridname=get(handles.grid_patch1,'String'); |
---|
2495 | if isequal(gridname(end-3:end),'grid') |
---|
2496 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2497 | if ~isempty(nbslice_grid) |
---|
2498 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
2499 | patch1.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2500 | if ~exist(patch1.gridPatch,'file') |
---|
2501 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
2502 | end |
---|
2503 | elseif exist(gridname,'file') |
---|
2504 | patch1.gridPatch=gridname; |
---|
2505 | else |
---|
2506 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
2507 | end |
---|
2508 | end |
---|
2509 | else |
---|
2510 | patch1.gridPatch='n'; |
---|
2511 | patch1.gridflag='n'; |
---|
2512 | patch1.m=nx_patch1; |
---|
2513 | patch1.n=ny_patch1; |
---|
2514 | end |
---|
2515 | patch1.convectFlow='n'; |
---|
2516 | fieldnames=fields(patch1); |
---|
2517 | [civAllxml,uid_patch1]=add(civAllxml,1,'element','patch1'); |
---|
2518 | for ilist=1:length(fieldnames) |
---|
2519 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
2520 | if ischar(val) |
---|
2521 | [civAllxml,uid_t]=add(civAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
2522 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2523 | end |
---|
2524 | end |
---|
2525 | civAllCmd=[civAllCmd ' patch1 ']; |
---|
2526 | end |
---|
2527 | end |
---|
2528 | |
---|
2529 | if box_test(4)==1 | box_test(5)==1 | box_test(6)==1 |
---|
2530 | filename_cmx=filecell.nc.civ2{ifile,j};%output netcdf file |
---|
2531 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
2532 | filename_cmx=[filename_cmx 'x']; |
---|
2533 | end |
---|
2534 | |
---|
2535 | if box_test(4)==1 |
---|
2536 | par_civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
2537 | %par_civ2.filename_ima_a([end-3:end])=[];%remove .png extension |
---|
2538 | par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
2539 | %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension |
---|
2540 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
2541 | par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
2542 | par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
2543 | par_civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
2544 | par_civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
2545 | par_civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
2546 | par_civ2.filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
2547 | test_mask=get(handles.get_mask_civ2,'Value'); |
---|
2548 | if test_mask==0 |
---|
2549 | par_civ2.maskname='noFile use default'; |
---|
2550 | par_civ2.maskflag='n'; |
---|
2551 | else |
---|
2552 | maskdispl=get(handles.mask_civ2,'String'); |
---|
2553 | if exist(maskdispl,'file') |
---|
2554 | par_civ2.maskname=maskdispl; |
---|
2555 | par_civ2.maskflag='y'; |
---|
2556 | else |
---|
2557 | maskbase=[filebase '_' maskdispl]; % |
---|
2558 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2559 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
2560 | par_civ2.maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2561 | if exist(par_civ2.maskname,'file') |
---|
2562 | par_civ2.maskflag='y'; |
---|
2563 | else |
---|
2564 | par_civ2.maskname='noFile use default'; |
---|
2565 | par_civ2.maskflag='n'; |
---|
2566 | end |
---|
2567 | end |
---|
2568 | end |
---|
2569 | %TESTgrid |
---|
2570 | test_grid=get(handles.browse_gridciv2,'Value'); |
---|
2571 | gridname=get(handles.grid_civ2,'String'); |
---|
2572 | gridflag='y'; |
---|
2573 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
2574 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2575 | if ~isempty(nbslice_grid) |
---|
2576 | par_civ2.gridflag='y'; |
---|
2577 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
2578 | par_civ2.gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2579 | if exist(par_civ2.gridname,'file') |
---|
2580 | par_civ2.gridflag='y'; |
---|
2581 | else |
---|
2582 | par_civ2.gridname='noFile use default'; |
---|
2583 | par_civ2.gridflag='n'; |
---|
2584 | end |
---|
2585 | elseif exist(gridname,'file') |
---|
2586 | par_civ2.gridflag='y'; |
---|
2587 | else |
---|
2588 | par_civ2.gridname='noFile use default'; |
---|
2589 | par_civ2.gridflag='n'; |
---|
2590 | end |
---|
2591 | end |
---|
2592 | %endTESTgrid |
---|
2593 | i_cmd=i_cmd+1; |
---|
2594 | cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par_civ2,sparam); |
---|
2595 | if isequal(civAll,0) |
---|
2596 | if(isunix) |
---|
2597 | cmd=[cmd '\n' 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
2598 | else |
---|
2599 | cmd=[cmd '\n' 'copy /Y ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2]; |
---|
2600 | end |
---|
2601 | else |
---|
2602 | civAllCmd=[civAllCmd ' civ2 ']; |
---|
2603 | str=BATCH_CIV2_Unified(filename_cmx([1:end-4]),namelog,par_civ2,sparam); |
---|
2604 | fieldnames=fields(str); |
---|
2605 | [civAllxml,uid_civ2]=add(civAllxml,1,'element','civ2'); |
---|
2606 | for ilist=1:length(fieldnames) |
---|
2607 | val=eval(['str.' fieldnames{ilist}]); |
---|
2608 | if ischar(val) |
---|
2609 | [civAllxml,uid_t]=add(civAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
2610 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2611 | end |
---|
2612 | end |
---|
2613 | end |
---|
2614 | end |
---|
2615 | |
---|
2616 | % FIX2 |
---|
2617 | if box_test(5)==1 |
---|
2618 | test_mask=get(handles.get_mask_fix2,'Value'); |
---|
2619 | if test_mask==0 |
---|
2620 | maskname=''; %no mask used |
---|
2621 | else |
---|
2622 | maskdispl=get(handles.mask_fix2,'String'); |
---|
2623 | maskbase=[filebase '_' maskdispl]; % |
---|
2624 | nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
2625 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
2626 | maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
2627 | end |
---|
2628 | if isequal(civAll,0) |
---|
2629 | cmd_FIX=[fixBin ' -f ' filecell.nc.civ2{ifile,j} ' -fi1 ' num2str(flagindex2(1)) ... |
---|
2630 | ' -fi2 ' num2str(flagindex2(2)) ' -fi3 ' num2str(flagindex2(3)) ... |
---|
2631 | ' -threshC ' num2str(thresh_vec2C) ' -threshV ' num2str(thresh_vel2) ' -maskName ' maskname]; |
---|
2632 | cmd=[cmd '\n' cmd_FIX]; |
---|
2633 | else |
---|
2634 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
2635 | fix2.fi1=num2str(flagindex2(1)); |
---|
2636 | fix2.fi2=num2str(flagindex2(2)); |
---|
2637 | fix2.fi3=num2str(flagindex2(3)); |
---|
2638 | fix2.threshC=num2str(thresh_vec2C); |
---|
2639 | fix2.threshV=num2str(thresh_vel2); |
---|
2640 | fieldnames=fields(fix2); |
---|
2641 | [civAllxml,uid_fix2]=add(civAllxml,1,'element','fix2'); |
---|
2642 | for ilist=1:length(fieldnames) |
---|
2643 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
2644 | if ischar(val) |
---|
2645 | [civAllxml,uid_t]=add(civAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
2646 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2647 | end |
---|
2648 | end |
---|
2649 | civAllCmd=[civAllCmd ' fix2 ']; |
---|
2650 | end |
---|
2651 | end |
---|
2652 | |
---|
2653 | %PATCH2 |
---|
2654 | if box_test(6)==1 |
---|
2655 | if isequal(civAll,0) |
---|
2656 | cmd_PATCH=RUN_PATCH(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp); |
---|
2657 | cmd=[cmd '\n' cmd_PATCH]; |
---|
2658 | else |
---|
2659 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
2660 | patch2.nopt=subdomain_patch1; |
---|
2661 | patch2.maxdiff=thresh_patch1; |
---|
2662 | patch2.ro=rho_patch1; |
---|
2663 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
2664 | if test_grid |
---|
2665 | patch2.gridflag='y'; |
---|
2666 | gridname=get(handles.grid_patch2,'String'); |
---|
2667 | if isequal(gridname(end-3:end),'grid') |
---|
2668 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
2669 | if ~isempty(nbslice_grid) |
---|
2670 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
2671 | patch2.gridPatch=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
2672 | if ~exist(patch2.gridPatch,'file') |
---|
2673 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
2674 | end |
---|
2675 | elseif exist(gridname,'file') |
---|
2676 | patch2.gridPatch=gridname; |
---|
2677 | else |
---|
2678 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
2679 | end |
---|
2680 | end |
---|
2681 | else |
---|
2682 | patch2.gridPatch='n'; |
---|
2683 | patch2.gridflag='n'; |
---|
2684 | patch2.m=nx_patch2; |
---|
2685 | patch2.n=ny_patch2; |
---|
2686 | end |
---|
2687 | patch2.convectFlow='n'; |
---|
2688 | fieldnames=fields(patch2); |
---|
2689 | [civAllxml,uid_patch2]=add(civAllxml,1,'element','patch2'); |
---|
2690 | for ilist=1:length(fieldnames) |
---|
2691 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
2692 | if ischar(val) |
---|
2693 | [civAllxml,uid_t]=add(civAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
2694 | [civAllxml,uid_t2]=add(civAllxml,uid_t,'chardata',val); |
---|
2695 | end |
---|
2696 | end |
---|
2697 | civAllCmd=[civAllCmd ' patch2 ']; |
---|
2698 | end |
---|
2699 | end |
---|
2700 | if isequal(civAll,1) |
---|
2701 | save(civAllxml,[filename_cmx([1:end-4]) '.xml']); |
---|
2702 | cmd=char({cmd;[CivBin ' -f ' [filename_cmx([1:end-4]) '.xml'] ' ' civAllCmd]}); |
---|
2703 | end |
---|
2704 | % create the .bat file: |
---|
2705 | if batch |
---|
2706 | [Rootbat,Filebat,extbat]=fileparts(filename_cmx); |
---|
2707 | filename_bat=fullfile(Rootbat,['job_' Filebat extbat]); |
---|
2708 | else |
---|
2709 | filename_bat=filename_cmx; |
---|
2710 | end |
---|
2711 | filename_bat(end-2:end)='bat'; |
---|
2712 | fid=fopen(filename_bat,'w'); |
---|
2713 | fprintf(fid,cmd); |
---|
2714 | fclose(fid); |
---|
2715 | %dlmwrite(filename_bat,cmd,'');%write commands in filename_bat |
---|
2716 | if batch |
---|
2717 | switch batch_mode |
---|
2718 | case 'sge' |
---|
2719 | pvalue=num2str((1-ind_answer)*500); |
---|
2720 | namelog=[filename_bat '.patch.log']; |
---|
2721 | ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]; |
---|
2722 | eval( ['!qsub -p ' pvalue ' -q civ.q -e ' filename_cmx(1:end-4) '.errors -o ' filename_cmx(1:end-4) '.log' ' ' filename_bat]); |
---|
2723 | end |
---|
2724 | |
---|
2725 | |
---|
2726 | |
---|
2727 | else |
---|
2728 | %% to lauch the jobs locally : |
---|
2729 | if(isunix) |
---|
2730 | eval(['!. ' filename_bat ' &']); |
---|
2731 | else |
---|
2732 | eval(['!' filename_bat ' &']); |
---|
2733 | end |
---|
2734 | % if(isunix) |
---|
2735 | % cmdtodo=['. ' filename_bat ];%removed for Mathieu tests %' && rm -f ' filename_bat] ; |
---|
2736 | % else |
---|
2737 | % cmdtodo=[filename_bat];%removed for Mathieu tests %' && del /F /Q ' filename_bat' ; |
---|
2738 | % end |
---|
2739 | % count= fprintf(p1,'%s\n', cmdtodo); |
---|
2740 | end |
---|
2741 | end |
---|
2742 | end |
---|
2743 | % if ~sge |
---|
2744 | % fclose(p1); |
---|
2745 | % fclose(p0); |
---|
2746 | % delete(name_lock); |
---|
2747 | % end |
---|
2748 | |
---|
2749 | set(handles.BATCH, 'Enable','On') |
---|
2750 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
2751 | |
---|
2752 | %save interface state |
---|
2753 | if isfield(filecell,'nc') |
---|
2754 | if isfield(filecell.nc,'civ2') |
---|
2755 | fileresu=filecell.nc.civ2{1,1}; |
---|
2756 | else |
---|
2757 | fileresu=filecell.nc.civ1{1,1}; |
---|
2758 | end |
---|
2759 | end |
---|
2760 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
2761 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
2762 | detect=1; |
---|
2763 | while detect==1 |
---|
2764 | namefigfull=[namedoc '.fig']; |
---|
2765 | hh=dir(namefigfull); |
---|
2766 | if ~isempty(hh) |
---|
2767 | detect=1; |
---|
2768 | namedoc=[namedoc '.0']; |
---|
2769 | else |
---|
2770 | detect=0; |
---|
2771 | end |
---|
2772 | end |
---|
2773 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
2774 | |
---|
2775 | %------------------------------------------------------------------------ |
---|
2776 | %OUTPUT: |
---|
2777 | % filecell: structure of input and output files |
---|
2778 | % .ima1.civ1{i,j}, .ima1.civ2{i,j}; set of first image names for correlations, for civ1 and civ2 |
---|
2779 | % .ima2.civ1{i,j}, .ima2.civ2{i,j} ; set of second image names for correlations |
---|
2780 | % .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) |
---|
2781 | % .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) |
---|
2782 | % .nc.civ1{i,j}, .nc.civ2{i,j}; set of nc files for PIV results |
---|
2783 | % .ncA.civ1{i,j}, .ncA.civ2{i,j}; set of nc files for PIV results with camA (then .nc corresponds to camB) |
---|
2784 | % .st{i,j}; set of nc files for the combined stereo fields |
---|
2785 | % num1_civ1(i),num2_civ1(i): lists of first and last i indices for civ1 |
---|
2786 | % num_a_civ1(j),num_b_civ1(j): lists of first and last j indices for civ1 |
---|
2787 | % num1_civ2(i),num2_civ2(i): lists of first and last i indices for civ2 |
---|
2788 | % num_a_civ2(j),num_b_civ2(j): lists of first and last j indices for civ2 |
---|
2789 | % nom_type_nc: nomenclature type for velocity files |
---|
2790 | % file_ref_fix1,file_ref_fix2: reference files possibly used by Fix1 and 2 |
---|
2791 | 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]=... |
---|
2792 | set_civ_filenames(handles,compare,box_test) |
---|
2793 | %------------------------------------------------------------------------ |
---|
2794 | %get the filename root, nomenclature and numbers |
---|
2795 | filebase=get(handles.RootName,'String'); |
---|
2796 | browse=get(handles.browse_root,'UserData'); |
---|
2797 | compare_list=get(handles.compare,'String'); |
---|
2798 | val=get(handles.compare,'Value'); |
---|
2799 | compare=compare_list{val}; |
---|
2800 | if strcmp(compare,'displacement') |
---|
2801 | mode='displacement'; |
---|
2802 | else |
---|
2803 | mode_list=get(handles.mode,'String'); |
---|
2804 | mode_value=get(handles.mode,'Value'); |
---|
2805 | mode=mode_list{mode_value}; |
---|
2806 | end |
---|
2807 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
2808 | ext_ima=get(handles.ImaExt,'String'); |
---|
2809 | nom_type_nc=browse.nom_type_nc; |
---|
2810 | nom_type_ima2=browse.nom_type_ima; |
---|
2811 | if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default |
---|
2812 | if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default |
---|
2813 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
2814 | find_pair_indices(handles,mode); |
---|
2815 | %determine the new filebase for 'displacement' mode (comparison of two series) |
---|
2816 | filebase_B=filebase;% root name of the second field series for stereo |
---|
2817 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
2818 | test_disp=1; |
---|
2819 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
2820 | [Path2,Name2]=fileparts(filebase_B); |
---|
2821 | Path1=Path2; |
---|
2822 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
2823 | filebase_A=fullfile(Path1,Name1); |
---|
2824 | if length(Name1)>6 |
---|
2825 | Name1=Name1(end-5:end); |
---|
2826 | end |
---|
2827 | if length(Name2)>6 |
---|
2828 | Name2=Name2(end-5:end); |
---|
2829 | end |
---|
2830 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
2831 | else |
---|
2832 | test_disp=0; |
---|
2833 | filebase_A=filebase; |
---|
2834 | nom_type_ima1=nom_type_ima2; |
---|
2835 | filebase_AB=filebase; |
---|
2836 | end |
---|
2837 | if strcmp(compare,'displacement') |
---|
2838 | filebase_ima1=filebase_A; |
---|
2839 | filebase_ima2=filebase_B; |
---|
2840 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
2841 | else |
---|
2842 | filebase_ima1=filebase_B; |
---|
2843 | filebase_ima2=filebase_B; |
---|
2844 | filebase_nc=filebase_B; |
---|
2845 | end |
---|
2846 | |
---|
2847 | %determine reference files for fix: |
---|
2848 | file_ref_fix1={};%default |
---|
2849 | file_ref_fix2={}; |
---|
2850 | nbfield=length(num1_civ1); |
---|
2851 | nbslice=length(num_a_civ1); |
---|
2852 | if box_test(2)==1% fix1 performed |
---|
2853 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
2854 | if ~isempty(ref) |
---|
2855 | first_i=str2num(get(handles.first_i,'String')); |
---|
2856 | last_i=str2num(get(handles.last_i,'String')); |
---|
2857 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
2858 | first_j=str2num(get(handles.first_j,'String')); |
---|
2859 | last_j=str2num(get(handles.last_j,'String')); |
---|
2860 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
2861 | num_i_ref=[first_i:incr_i:last_i]; |
---|
2862 | num_j_ref=[first_j:incr_j:last_j]; |
---|
2863 | if isequal(mode,'displacement') |
---|
2864 | num_i1=num_i_ref; |
---|
2865 | num_i2=num_i_ref; |
---|
2866 | num_j1=num_j_ref; |
---|
2867 | num_j2=num_j_ref; |
---|
2868 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
2869 | num_i1=num_i_ref; |
---|
2870 | num_i2=num_i1; |
---|
2871 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
2872 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
2873 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
2874 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2875 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2876 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2877 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2878 | if isempty(ref.num_a) |
---|
2879 | ref.num_a=1; |
---|
2880 | end |
---|
2881 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2882 | num_j2=num_j1; |
---|
2883 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
2884 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2885 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2886 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2887 | num_i2=num_i1; |
---|
2888 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2889 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2890 | end |
---|
2891 | for ifile=1:nbfield |
---|
2892 | for j=1:nbslice |
---|
2893 | 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);% |
---|
2894 | file_ref_fix1(ifile,j)={file_ref}; |
---|
2895 | if ~exist(file_ref,'file') |
---|
2896 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
2897 | filecell=[]; |
---|
2898 | return |
---|
2899 | end |
---|
2900 | end |
---|
2901 | end |
---|
2902 | end |
---|
2903 | end |
---|
2904 | |
---|
2905 | %determine reference files for fix2: |
---|
2906 | if box_test(5)==1% fix2 performed |
---|
2907 | ref=get(handles.ref_fix2,'UserData'); |
---|
2908 | if ~isempty(ref) |
---|
2909 | first_i=str2num(get(handles.first_i,'String')); |
---|
2910 | last_i=str2num(get(handles.last_i,'String')); |
---|
2911 | incr_i=str2num(get(handles.incr_i,'String')); |
---|
2912 | first_j=str2num(get(handles.first_j,'String')); |
---|
2913 | last_j=str2num(get(handles.last_j,'String')); |
---|
2914 | incr_j=str2num(get(handles.incr_j,'String')); |
---|
2915 | num_i_ref=[first_i:incr_i:last_i]; |
---|
2916 | num_j_ref=[first_j:incr_j:last_j]; |
---|
2917 | if isequal(mode,'displacement') |
---|
2918 | num_i1=num_i_ref; |
---|
2919 | num_i2=num_i_ref; |
---|
2920 | num_j1=num_j_ref; |
---|
2921 | num_j2=num_j_ref; |
---|
2922 | elseif isequal(mode,'pair j1-j2') |
---|
2923 | num_i1=num_i_ref; |
---|
2924 | num_i2=num_i1; |
---|
2925 | num_j1=ref.num_a; |
---|
2926 | num_j2=ref.num_b; |
---|
2927 | elseif isequal(mode,'series(Di)') |
---|
2928 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2929 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2930 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2931 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2932 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2933 | num_j2=num_j1; |
---|
2934 | elseif isequal(mode,'series(Dj)') |
---|
2935 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2936 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2937 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2938 | num_i2=num_i1; |
---|
2939 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2940 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2941 | end |
---|
2942 | for ifile=1:nbfield |
---|
2943 | for j=1:nbslice |
---|
2944 | 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);% |
---|
2945 | file_ref_fix2(ifile,j)={file_ref}; |
---|
2946 | if ~exist(file_ref,'file') |
---|
2947 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
2948 | filecell=[]; |
---|
2949 | return |
---|
2950 | end |
---|
2951 | end |
---|
2952 | end |
---|
2953 | end |
---|
2954 | end |
---|
2955 | |
---|
2956 | %check dir |
---|
2957 | subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
2958 | subdir_civ2=get(handles.subdir_civ2,'String'); |
---|
2959 | if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir |
---|
2960 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
2961 | currentdir=pwd;%store the current working directory |
---|
2962 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
2963 | if ~exist(Path_ima,'dir') |
---|
2964 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
2965 | filecell=[]; |
---|
2966 | return |
---|
2967 | end |
---|
2968 | cd(Path_ima);%move to the directory of the images: needed to create the result dir by 'mkdir' |
---|
2969 | dircur=pwd; %current working directory |
---|
2970 | m2=''; |
---|
2971 | [erread,message]=fileattrib(Path_ima); |
---|
2972 | if ~isempty(message) & ~isequal(message.UserWrite,1) |
---|
2973 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
2974 | filecell=[]; |
---|
2975 | cd(currentdir); |
---|
2976 | return |
---|
2977 | end |
---|
2978 | |
---|
2979 | %check the existence of the netcdf and image files involved |
---|
2980 | % %%%%%%%%%%%% case CIV1 activated %%%%%%%%%%%%% |
---|
2981 | if box_test(1)==1; |
---|
2982 | detect=1; |
---|
2983 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
2984 | for ifile=1:nbfield; |
---|
2985 | for j=1:nbslice |
---|
2986 | 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); |
---|
2987 | detect=exist(filename,'file')==2; |
---|
2988 | if detect% if a netcdf file already exists |
---|
2989 | subdir_civ1=[subdir_civ1 '.0']; |
---|
2990 | subdir_civ2=subdir_civ1; |
---|
2991 | break |
---|
2992 | end |
---|
2993 | filecell.nc.civ1(ifile,j)={filename}; |
---|
2994 | end |
---|
2995 | if detect% if a netcdf file already exists |
---|
2996 | break |
---|
2997 | end |
---|
2998 | end |
---|
2999 | %create the new subdir_civ1 |
---|
3000 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
3001 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
3002 | if ~isequal(m2,'') |
---|
3003 | msgbox_uvmat('ERROR', m2) |
---|
3004 | %msgbox(m2);%error message for directory creation |
---|
3005 | end |
---|
3006 | end |
---|
3007 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
3008 | for ifile=1:nbfield |
---|
3009 | for j=1:nbslice |
---|
3010 | 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);% |
---|
3011 | detect=exist(filename,'file')==2; |
---|
3012 | if detect% if a netcdf file already exists |
---|
3013 | subdir_civ1=[subdir_civ1 '.0']; |
---|
3014 | subdir_civ2=subdir_civ1; |
---|
3015 | break |
---|
3016 | end |
---|
3017 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
3018 | end |
---|
3019 | if detect% if a netcdf file already exists |
---|
3020 | break |
---|
3021 | end |
---|
3022 | end |
---|
3023 | %create the new subdir_civ1 |
---|
3024 | if ~exist(fullfile(Path_ima,subdir_civ1),'dir') |
---|
3025 | [m1,m2,m3]=mkdir(subdir_civ1); |
---|
3026 | if ~isequal(m2,'') |
---|
3027 | msgbox_uvmat('ERROR', m2) |
---|
3028 | end |
---|
3029 | end |
---|
3030 | end |
---|
3031 | end |
---|
3032 | % get image names |
---|
3033 | for ifile=1:nbfield |
---|
3034 | for j=1:nbslice |
---|
3035 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
3036 | idetect(j)=exist(filename,'file')==2; |
---|
3037 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
3038 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
3039 | idetect_1(j)=exist(filename,'file')==2; |
---|
3040 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
3041 | end |
---|
3042 | [idetectmin,indexj]=min(idetect); |
---|
3043 | if idetectmin==0, |
---|
3044 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
3045 | filecell=[]; |
---|
3046 | return |
---|
3047 | end |
---|
3048 | [idetectmin,indexj]=min(idetect_1); |
---|
3049 | if idetectmin==0, |
---|
3050 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
3051 | filecell=[]; |
---|
3052 | cd(currentdir) |
---|
3053 | return |
---|
3054 | end |
---|
3055 | end |
---|
3056 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
3057 | for ifile=1:nbfield |
---|
3058 | for j=1:nbslice |
---|
3059 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
3060 | idetect(j)=exist(filename,'file')==2; |
---|
3061 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
3062 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
3063 | idetect_1(j)=exist(filename,'file')==2; |
---|
3064 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
3065 | end |
---|
3066 | [idetectmin,indexj]=min(idetect); |
---|
3067 | if idetectmin==0, |
---|
3068 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
3069 | filecell=[]; |
---|
3070 | cd(currentdir) |
---|
3071 | return |
---|
3072 | end |
---|
3073 | [idetectmin,indexj]=min(idetect_1); |
---|
3074 | if idetectmin==0, |
---|
3075 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
3076 | filecell=[]; |
---|
3077 | cd(currentdir) |
---|
3078 | return |
---|
3079 | end |
---|
3080 | end |
---|
3081 | end |
---|
3082 | |
---|
3083 | %%%%%%%%%%%%% fix1 or patch1 activated but no civ1 %%%%%%%%%%%%% |
---|
3084 | elseif (box_test(2)==1 || box_test(3)==1); |
---|
3085 | for ifile=1:nbfield |
---|
3086 | for j=1:nbslice |
---|
3087 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
3088 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
3089 | detect=exist(filename,'file')==2; |
---|
3090 | filecell.nc.civ1(ifile,j)={filename}; |
---|
3091 | end |
---|
3092 | end |
---|
3093 | if strcmp(compare,'stereo PIV') |
---|
3094 | for ifile=1:nbfield |
---|
3095 | for j=1:nbslice |
---|
3096 | 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);% |
---|
3097 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
3098 | if ~exist(filename,'file') |
---|
3099 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3100 | set(handles.RUN, 'Enable','On') |
---|
3101 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
3102 | set(handles.BATCH, 'Enable','On') |
---|
3103 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
3104 | filecell=[]; |
---|
3105 | cd(currentdir) |
---|
3106 | return |
---|
3107 | end |
---|
3108 | end |
---|
3109 | end |
---|
3110 | end |
---|
3111 | end |
---|
3112 | |
---|
3113 | %%%%%%%%%%%%% if civ2 performed with pairs different than civ1 %%%%%%%%%%%%% |
---|
3114 | testdiff=0; |
---|
3115 | if (box_test(4)==1)&&... |
---|
3116 | ((get(handles.list_pair_civ1,'Value')~=get(handles.list_pair_civ2,'Value'))||~isequal(subdir_civ2,subdir_civ1)) |
---|
3117 | testdiff=1; |
---|
3118 | detect=1; |
---|
3119 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
3120 | for ifile=1:nbfield |
---|
3121 | for j=1:nbslice |
---|
3122 | 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);% |
---|
3123 | detect=exist(filename,'file')==2; |
---|
3124 | if detect% if a netcdf file already exists |
---|
3125 | subdir_civ2=[subdir_civ2 '.0']; |
---|
3126 | break |
---|
3127 | end |
---|
3128 | filecell.nc.civ2(ifile,j)={filename}; |
---|
3129 | end |
---|
3130 | if detect% if a netcdf file already exists |
---|
3131 | break |
---|
3132 | end |
---|
3133 | end |
---|
3134 | %create the new subdir_civ2 |
---|
3135 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
3136 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
3137 | if ~isequal(m2,'') |
---|
3138 | msgbox_uvmat('ERROR', m2) |
---|
3139 | end |
---|
3140 | end |
---|
3141 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
3142 | for ifile=1:nbfield |
---|
3143 | for j=1:nbslice |
---|
3144 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3145 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);% |
---|
3146 | detect=exist(filename,'file')==2; |
---|
3147 | if detect% if a netcdf file already exists |
---|
3148 | subdir_civ2=[subdir_civ2 '.0']; |
---|
3149 | break |
---|
3150 | end |
---|
3151 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
3152 | end |
---|
3153 | if detect% if a netcdf file already exists |
---|
3154 | break |
---|
3155 | end |
---|
3156 | end |
---|
3157 | %create the new subdir_civ1 |
---|
3158 | if ~exist(fullfile(Path_ima,subdir_civ2),'dir') |
---|
3159 | [m1,m2,m3]=mkdir(subdir_civ2); |
---|
3160 | if ~isequal(m2,'') |
---|
3161 | msgbox_uvmat('ERROR', m2) |
---|
3162 | %msgbox(m2);%error message for directory creation |
---|
3163 | end |
---|
3164 | end |
---|
3165 | end |
---|
3166 | end |
---|
3167 | end |
---|
3168 | cd(currentdir);%come back to the current working directory |
---|
3169 | |
---|
3170 | |
---|
3171 | %%%%%%%%%%%%% if civ2 results are obtained or used %%%%%%%%%%%%% |
---|
3172 | if box_test(4)==1 || box_test(5)==1 || box_test(6)==1 %civ2 |
---|
3173 | %check source netcdf file of civ1 estimates |
---|
3174 | if box_test(1)==0; %no civ1 performed |
---|
3175 | for ifile=1:nbfield |
---|
3176 | for j=1:nbslice |
---|
3177 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
3178 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
3179 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
3180 | if ~exist(filename,'file') |
---|
3181 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3182 | filecell=[]; |
---|
3183 | return |
---|
3184 | end |
---|
3185 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
3186 | if box_test(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
3187 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
3188 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
3189 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
3190 | filecell=[]; |
---|
3191 | return |
---|
3192 | end |
---|
3193 | elseif box_test(3)==0; %check the existence of patch if it is not calculated |
---|
3194 | Data=nc2struct(filename,'ListGlobalAttribute','patch'); |
---|
3195 | if isempty(Data.patch)||isequal(Data.patch,0) |
---|
3196 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
3197 | filecell=[]; |
---|
3198 | return |
---|
3199 | end |
---|
3200 | end |
---|
3201 | end |
---|
3202 | end |
---|
3203 | end |
---|
3204 | if strcmp(compare,'stereo PIV') |
---|
3205 | for ifile=1:nbfield |
---|
3206 | for j=1:nbslice |
---|
3207 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3208 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
3209 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
3210 | if ~exist(filename,'file') |
---|
3211 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3212 | set(handles.RUN, 'Enable','On') |
---|
3213 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
3214 | set(handles.BATCH, 'Enable','On') |
---|
3215 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
3216 | cd(currentdir) |
---|
3217 | return |
---|
3218 | end |
---|
3219 | end |
---|
3220 | end |
---|
3221 | end |
---|
3222 | end |
---|
3223 | |
---|
3224 | detect=1; |
---|
3225 | % while detect==1%creates a new subdir if the netcdf files already contain civ2 data |
---|
3226 | for ifile=1:nbfield |
---|
3227 | for j=1:nbslice |
---|
3228 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3229 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
3230 | detect=exist(filename,'file')==2; |
---|
3231 | filecell.nc.civ2(ifile,j)={filename}; |
---|
3232 | end |
---|
3233 | end |
---|
3234 | %get first image names for civ2 |
---|
3235 | if box_test(1)==1 & isequal(num1_civ1,num1_civ2) & isequal(num_a_civ1,num_a_civ2) |
---|
3236 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
3237 | elseif box_test(4)==1 |
---|
3238 | for ifile=1:nbfield |
---|
3239 | for j=1:nbslice |
---|
3240 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
3241 | idetect_2(j)=exist(filename,'file')==2; |
---|
3242 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
3243 | end |
---|
3244 | [idetectmin,indexj]=min(idetect_2); |
---|
3245 | if idetectmin==0, |
---|
3246 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
3247 | filecell=[]; |
---|
3248 | return |
---|
3249 | end |
---|
3250 | end |
---|
3251 | end |
---|
3252 | |
---|
3253 | %get second image names for civ2 |
---|
3254 | if box_test(1)==1 & isequal(num2_civ1,num2_civ2) & isequal(num_b_civ1,num_b_civ2) |
---|
3255 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
3256 | elseif box_test(4)==1 |
---|
3257 | for ifile=1:nbfield |
---|
3258 | for j=1:nbslice |
---|
3259 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
3260 | idetect_3(j)=exist(filename,'file')==2; |
---|
3261 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
3262 | end |
---|
3263 | [idetectmin,indexj]=min(idetect_3); |
---|
3264 | if idetectmin==0, |
---|
3265 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
3266 | filecell=[]; |
---|
3267 | return |
---|
3268 | end |
---|
3269 | end |
---|
3270 | end |
---|
3271 | end |
---|
3272 | if (box_test(5)==1 || box_test(6)==1 ) && box_test(4)==0 % need to read an existing netcdf civ2 file |
---|
3273 | if ~testdiff |
---|
3274 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
3275 | else % check the civ2 files |
---|
3276 | for ifile=1:nbfield |
---|
3277 | for j=1:nbslice |
---|
3278 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3279 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
3280 | filecell.nc.civ2(ifile,j)={filename}; |
---|
3281 | if ~exist(filename,'file') |
---|
3282 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
3283 | filecell=[]; |
---|
3284 | return |
---|
3285 | else |
---|
3286 | Data=nc2struct(filename,'ListGlobalAttribute','civ2'); |
---|
3287 | if isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
3288 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
3289 | filecell=[]; |
---|
3290 | return |
---|
3291 | end |
---|
3292 | end |
---|
3293 | end |
---|
3294 | end |
---|
3295 | end |
---|
3296 | end |
---|
3297 | |
---|
3298 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
3299 | if strcmp(compare,'stereo PIV') |
---|
3300 | if box_test(3)==1 & isequal(get(handles.test_stereo1,'Value'),1) |
---|
3301 | for ifile=1:nbfield |
---|
3302 | for j=1:nbslice |
---|
3303 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
3304 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
3305 | filecell.st(ifile,j)={filename}; |
---|
3306 | end |
---|
3307 | end |
---|
3308 | end |
---|
3309 | if box_test(6)==1 & isequal(get(handles.test_stereo2,'Value'),1) |
---|
3310 | for ifile=1:nbfield |
---|
3311 | for j=1:nbslice |
---|
3312 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
3313 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
3314 | filecell.st(ifile,j)={filename}; |
---|
3315 | end |
---|
3316 | end |
---|
3317 | end |
---|
3318 | end |
---|
3319 | set(handles.subdir_civ1,'String',subdir_civ1);%update the edit box |
---|
3320 | set(handles.subdir_civ2,'String',subdir_civ2);%update the edit box |
---|
3321 | browse.nom_type_nc=nom_type_nc; |
---|
3322 | set(handles.browse_root,'UserData',browse); %update the nomenclature type for uvmat |
---|
3323 | |
---|
3324 | |
---|
3325 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
3326 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
3327 | nom_type_imanew1='_i'; |
---|
3328 | else |
---|
3329 | nom_type_imanew1=nom_type_ima1; |
---|
3330 | end |
---|
3331 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
3332 | nom_type_imanew2='_i'; |
---|
3333 | else |
---|
3334 | nom_type_imanew2=nom_type_ima2; |
---|
3335 | end |
---|
3336 | if ~isequal(ext_ima,'.png') |
---|
3337 | %%type of image file |
---|
3338 | type_ima1='none';%default |
---|
3339 | movieobject1=[];%default |
---|
3340 | if isequal(lower(ext_ima),'.avi') |
---|
3341 | hhh=which('mmreader'); |
---|
3342 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
3343 | type_ima1='movie'; |
---|
3344 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
3345 | else |
---|
3346 | type_ima1='avi'; |
---|
3347 | end |
---|
3348 | else |
---|
3349 | form=imformats(ext_ima(2:end)); |
---|
3350 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
3351 | if isequal(nom_type_ima1,'*'); |
---|
3352 | type_ima1='multimage';%image series in a single image file |
---|
3353 | else |
---|
3354 | type_ima1='image'; |
---|
3355 | end |
---|
3356 | end |
---|
3357 | end |
---|
3358 | type_ima2='none';%default |
---|
3359 | movieobject2=[]; |
---|
3360 | if isequal(lower(ext_ima),'.avi') |
---|
3361 | hhh=which('mmreader'); |
---|
3362 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
3363 | type_ima2='movie'; |
---|
3364 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
3365 | else |
---|
3366 | type_ima2='avi'; |
---|
3367 | end |
---|
3368 | else |
---|
3369 | form=imformats(ext_ima(2:end)); |
---|
3370 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
3371 | if isequal(nom_type_ima1,'*'); |
---|
3372 | type_ima2='multimage';%image series in a single image file |
---|
3373 | else |
---|
3374 | type_ima2='image'; |
---|
3375 | end |
---|
3376 | end |
---|
3377 | end |
---|
3378 | %npxy=get(handles.ImaExt,'UserData'); |
---|
3379 | % % if numel(npxy)<2 |
---|
3380 | % |
---|
3381 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
3382 | % A=imread(filename); |
---|
3383 | % npxy=size(A); |
---|
3384 | % % end |
---|
3385 | % npy=npxy(1); |
---|
3386 | % npx=npxy(2); |
---|
3387 | if box_test(1)==1 %if civ1 is performed |
---|
3388 | h = waitbar(0,['copy images to the .png format for civ1']);% display a wait bar |
---|
3389 | for ifile=1:nbfield |
---|
3390 | waitbar(ifile/nbfield); |
---|
3391 | for j=1:nbslice |
---|
3392 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
3393 | if ~exist(filename,'file') |
---|
3394 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
3395 | imwrite(A,filename,'BitDepth',16); |
---|
3396 | end |
---|
3397 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
3398 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
3399 | if ~exist(filename,'file') |
---|
3400 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
3401 | imwrite(A,filename,'BitDepth',16); |
---|
3402 | end |
---|
3403 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
3404 | end |
---|
3405 | end |
---|
3406 | close(h) |
---|
3407 | end |
---|
3408 | if box_test(4)==1 %if civ2 is performed |
---|
3409 | h = waitbar(0,['copy images to the .png format for civ2']);% display a wait bar |
---|
3410 | for ifile=1:nbfield |
---|
3411 | waitbar(ifile/nbfield); |
---|
3412 | for j=1:nbslice |
---|
3413 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
3414 | if ~exist(filename,'file') |
---|
3415 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),nom_type_ima2,num1_civ2(ifile)); |
---|
3416 | imwrite(A,filename,'BitDepth',16); |
---|
3417 | end |
---|
3418 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
3419 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
3420 | if ~exist(filename,'file') |
---|
3421 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),nom_type_ima2,num2.civ1(ifile)); |
---|
3422 | imwrite(A,filename,'BitDepth',16); |
---|
3423 | end |
---|
3424 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
3425 | end |
---|
3426 | end |
---|
3427 | close(h); |
---|
3428 | end |
---|
3429 | end |
---|
3430 | |
---|
3431 | %------------------------------------------------------------------------ |
---|
3432 | %CIV1 CIV1 CIV1 CIV1 |
---|
3433 | function RUN_CIV1(handles,filecell,filecell_1,filecell_nc1,num1,num2,num_a,num_b,nom_type_nc) |
---|
3434 | %------------------------------------------------------------------------ |
---|
3435 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
3436 | global civ1Bin sge%name of the executable for civ1 calculation |
---|
3437 | |
---|
3438 | %get civ parameters |
---|
3439 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
3440 | if isempty(ibx_val) |
---|
3441 | ibx='21'; set(handles.ibx,'String','21') |
---|
3442 | else |
---|
3443 | ibx=num2str(ibx_val); |
---|
3444 | end |
---|
3445 | iby_val=str2num(get(handles.iby,'String')); |
---|
3446 | if isempty(iby_val) |
---|
3447 | iby='21'; set(handles.iby,'String','21') |
---|
3448 | else |
---|
3449 | iby=num2str(iby_val); |
---|
3450 | end |
---|
3451 | isx=get(handles.isx,'String'); |
---|
3452 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
3453 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
3454 | isy=get(handles.isy,'String'); |
---|
3455 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
3456 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
3457 | shiftx=get(handles.shiftx,'String'); |
---|
3458 | if isempty(str2num(shiftx)), shiftx='0'; set(handles.shiftx,'String','0'), end;%default |
---|
3459 | shifty=get(handles.shifty,'String'); |
---|
3460 | if isempty(str2num(shifty)), shifty='0'; set(handles.shifty,'String','0'), end;%default |
---|
3461 | rho=get(handles.rho,'String'); |
---|
3462 | dx=get(handles.dx_civ1,'String'); |
---|
3463 | if isequal(str2num(dx),[]), dx='20'; set(handles.dx_civ1,'String','20'); end%default |
---|
3464 | dy=get(handles.dy_civ1,'String'); |
---|
3465 | if isequal(str2num(dy),[]), dy='20'; set(handles.dy_civ1,'String','20');end %default |
---|
3466 | if isequal(str2num(dy),[]), dy='20'; end%default |
---|
3467 | pxcmx='1'; %velocity fields are expressed in pixel displacement |
---|
3468 | pxcmy='1'; |
---|
3469 | image_first=cell2mat(filecell(1,1)); |
---|
3470 | if ~exist(image_first,'file') |
---|
3471 | msgbox_uvmat('ERROR',['image ' image_first 'not found']) |
---|
3472 | set(handles.RUN, 'Enable','On') |
---|
3473 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
3474 | return |
---|
3475 | end |
---|
3476 | A=imread(cell2mat(filecell(1,1)));%read the first image to get the size |
---|
3477 | sizim=size(A); |
---|
3478 | npx=num2str(sizim(2)); |
---|
3479 | npy=num2str(sizim(1)); |
---|
3480 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
3481 | gridname='';%default ='noFile use default' |
---|
3482 | gridflag='n';%default |
---|
3483 | test_grid=get(handles.browse_gridciv1,'Value'); |
---|
3484 | nbslice_grid=[]; |
---|
3485 | if test_grid |
---|
3486 | gridname=get(handles.grid_civ1,'String'); |
---|
3487 | if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
3488 | nbslice_grid=str2num(gridname(1:end-4)); % |
---|
3489 | if ~isempty(nbslice_grid) |
---|
3490 | gridflag='y'; |
---|
3491 | end |
---|
3492 | elseif exist(gridname,'file') |
---|
3493 | gridflag='y'; |
---|
3494 | else |
---|
3495 | msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
3496 | return |
---|
3497 | end |
---|
3498 | end |
---|
3499 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
3500 | threshflag='y'; |
---|
3501 | min_ima=get(handles.MinIma,'String'); |
---|
3502 | max_ima=get(handles.MaxIma,'String'); |
---|
3503 | else |
---|
3504 | threshflag='n'; |
---|
3505 | min_ima='0'; |
---|
3506 | max_ima='4096'; |
---|
3507 | end |
---|
3508 | %main loop |
---|
3509 | filebase=get(handles.RootName,'String'); |
---|
3510 | sizcell=size(filecell); |
---|
3511 | nbfield=sizcell(1); |
---|
3512 | nbslice=sizcell(2); |
---|
3513 | icount=0; |
---|
3514 | for ifile=1:nbfield |
---|
3515 | for j=1:nbslice |
---|
3516 | icount=icount+1; |
---|
3517 | barlength=0.188*icount/(nbfield*nbslice); |
---|
3518 | set(handles.waitbar_1,'Position',[0.946 0.877-barlength 0.03 barlength]) |
---|
3519 | drawnow |
---|
3520 | filename_ima=cell2mat(filecell(ifile,j)); |
---|
3521 | filename_ima([end-3:end])=[];%remove .png extension |
---|
3522 | filename_ima_1=cell2mat(filecell_1(ifile,j)); |
---|
3523 | filename_ima_1([end-3:end])=[];%remove .png extension |
---|
3524 | filename_cmx=cell2mat(filecell_nc1(ifile,j));%output netcdf file |
---|
3525 | filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
3526 | filename_cmx=[filename_cmx 'x']; |
---|
3527 | namelog=[filename_cmx([1:end-3]) 'log']; |
---|
3528 | if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
3529 | Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
3530 | if isequal(Dt,'0') |
---|
3531 | Dt='1' ;%case of 'displacement' mode |
---|
3532 | end |
---|
3533 | T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
3534 | else |
---|
3535 | Dt='1'; |
---|
3536 | T0='0'; |
---|
3537 | end |
---|
3538 | term_a=num2stra(num_a(j),nom_type_nc);%UTILITE? |
---|
3539 | term_b=num2stra(num_b(j),nom_type_nc);% |
---|
3540 | if test_grid && ~isempty(nbslice_grid) |
---|
3541 | num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
3542 | gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
3543 | if ~exist(gridname,'file') |
---|
3544 | msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
3545 | return |
---|
3546 | end |
---|
3547 | end |
---|
3548 | test_mask=get(handles.get_mask_civ1,'Value'); |
---|
3549 | if test_mask==0 |
---|
3550 | maskname='noFile use default'; |
---|
3551 | maskflag='n'; |
---|
3552 | else |
---|
3553 | maskdispl=get(handles.mask_civ1,'String');%look for mask name in edit box |
---|
3554 | maskbase=[filebase '_' maskdispl];% |
---|
3555 | nbslice=str2num(maskdispl(1:end-4)); % |
---|
3556 | num1_mask=mod(num1(ifile)-1,nbslice)+1; |
---|
3557 | maskname=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
3558 | if exist(maskname,'file') |
---|
3559 | maskflag='y'; |
---|
3560 | else |
---|
3561 | maskname='noFile use default'; |
---|
3562 | maskflag='n'; |
---|
3563 | end |
---|
3564 | end |
---|
3565 | textcmx={'############## CMX file';... |
---|
3566 | ['FirstImage ' filename_ima];... |
---|
3567 | ['LastImage ' filename_ima_1];... |
---|
3568 | 'XX' ;... |
---|
3569 | ['Mask ' maskflag] ;... |
---|
3570 | ['MaskName ' maskname];... |
---|
3571 | ['ImageSize ' npx ' ' npy];... %VERIFIER CAS GENERAL ? |
---|
3572 | ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
3573 | ['SearchBoxeSize ' isx ' ' isy];... |
---|
3574 | ['RO ' rho];... |
---|
3575 | ['GridSpacing ' dx ' ' dy];... |
---|
3576 | 'XX 1.0';... |
---|
3577 | ['Dt_TO ' Dt ' ' T0];... |
---|
3578 | ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
3579 | 'XX 1';... |
---|
3580 | ['ShiftXY ' shiftx ' ' shifty];... |
---|
3581 | ['Grid ' gridflag];... |
---|
3582 | ['GridName ' gridname] ;... |
---|
3583 | 'XX 85';... |
---|
3584 | 'XX 1.0';... |
---|
3585 | 'XX 1.0';... |
---|
3586 | 'Hart 1';... |
---|
3587 | 'DecimalShift 0';... |
---|
3588 | 'Deformation 0';... |
---|
3589 | 'CorrelationMin 0';... |
---|
3590 | 'IntensityMin 0';... |
---|
3591 | ['SeuilImage ' threshflag];... |
---|
3592 | ['SeuilImageValues ' min_ima ' ' max_ima];... |
---|
3593 | ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
3594 | 'ImageUsedBefore null null'}; |
---|
3595 | textout=char(textcmx); |
---|
3596 | % dlmwrite(filename_cmx,textout,''); |
---|
3597 | fid=fopen([filename_cmx],'w'); |
---|
3598 | fprintf(fid, ['############## CMX file' '\n']); |
---|
3599 | fprintf(fid, ['FirstImage ' regexprep(filename_ima,'\\','\\\\') '\n' ]); |
---|
3600 | fprintf(fid, ['LastImage ' regexprep(filename_ima_1,'\\','\\\\') '\n' ]); |
---|
3601 | fprintf(fid, ['XX' '\n' ]); |
---|
3602 | fprintf(fid, ['Mask ' maskflag '\n' ]); |
---|
3603 | fprintf(fid, ['MaskName ' maskname '\n' ]); |
---|
3604 | fprintf(fid, ['ImageSize ' npx ' ' npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
3605 | fprintf(fid, ['CorrelationBoxesSize ' ibx ' ' iby '\n' ]); |
---|
3606 | fprintf(fid, ['SearchBoxeSize ' isx ' ' isy '\n' ]); |
---|
3607 | fprintf(fid, ['RO ' rho '\n' ]); |
---|
3608 | fprintf(fid, ['GridSpacing ' dx ' ' dy '\n' ]); |
---|
3609 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
3610 | fprintf(fid, ['Dt_TO ' Dt ' ' T0 '\n' ]); |
---|
3611 | fprintf(fid, ['PixCmXY ' pxcmx ' ' pxcmy '\n' ]); |
---|
3612 | fprintf(fid, ['XX 1' '\n' ]); |
---|
3613 | fprintf(fid, ['ShiftXY ' shiftx ' ' shifty '\n' ]); |
---|
3614 | fprintf(fid, ['Grid ' gridflag '\n' ]); |
---|
3615 | fprintf(fid, ['GridName ' gridname '\n' ]); |
---|
3616 | fprintf(fid, ['XX 85' '\n' ]); |
---|
3617 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
3618 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
3619 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
3620 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
3621 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
3622 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
3623 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
3624 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
3625 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
3626 | fprintf(fid, ['ImageToUse ' term_a ' ' term_b '\n' ]); % VERIFIER ? |
---|
3627 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
3628 | fclose(fid); |
---|
3629 | |
---|
3630 | s=-1; |
---|
3631 | display(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]) |
---|
3632 | eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog ]); |
---|
3633 | % if sge%dispatch computation on the cluster using interactive queue |
---|
3634 | % % [s,w] = unix(['qrsh -q fast.q ' civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1' ]); |
---|
3635 | % end |
---|
3636 | % if s~=0 |
---|
3637 | % % ['!' civ1Bin ' -f ' filename_cmx ' > ' namelog] |
---|
3638 | % % eval(['!' civ1Bin ' -f ' filename_cmx ' > ' namelog]); |
---|
3639 | % end |
---|
3640 | end |
---|
3641 | end |
---|
3642 | |
---|
3643 | % %------------------------------------------------------------------------ |
---|
3644 | % % RUN CIV2 CIV2 CIV2 CIV2 |
---|
3645 | % function RUN_CIV2(handles,filecell_2,filecell_3,filecell_nc1,filecell_nc2,num1,num2,num_a,num_b,nom_type_nc) |
---|
3646 | % %------------------------------------------------------------------------ |
---|
3647 | % %filecell_2: names of first image |
---|
3648 | % %filecell_3: names of second images |
---|
3649 | % global civ2Bin sge |
---|
3650 | % |
---|
3651 | % %names of the civ2 fields |
---|
3652 | % field.vel_type='civ2'; |
---|
3653 | % field.nb='nb_vectors2'; |
---|
3654 | % field.X='vec2_X'; |
---|
3655 | % field.Y='vec2_Y'; |
---|
3656 | % field.U='vec2_U'; |
---|
3657 | % field.V='vec2_V'; |
---|
3658 | % |
---|
3659 | % %get civ parameters |
---|
3660 | % ibx=get(handles.ibx_civ2,'String'); |
---|
3661 | % iby=get(handles.iby_civ2,'String'); |
---|
3662 | % rho=get(handles.rho_civ2,'String'); |
---|
3663 | % decimal=int2str(get(handles.decimal,'Value')); |
---|
3664 | % deformation=int2str(get(handles.deformation,'Value')); |
---|
3665 | % dx=get(handles.dx_civ2,'String'); |
---|
3666 | % dy=get(handles.dy_civ2,'String'); |
---|
3667 | % if isequal(str2num(dx),[]) |
---|
3668 | % dx='20';%default |
---|
3669 | % end |
---|
3670 | % if isequal(str2num(dy),[]) |
---|
3671 | % dy='20';%default |
---|
3672 | % end |
---|
3673 | % pxcmx='1';%velocity fields are expressed in pixel displacement |
---|
3674 | % pxcmy='1'; |
---|
3675 | % A=imread(cell2mat(filecell_2(1,1)));%read the first image to get the size |
---|
3676 | % sizim=size(A); |
---|
3677 | % npx=num2str(sizim(2)); |
---|
3678 | % npy=num2str(sizim(1)); |
---|
3679 | % time=get(handles.RootName,'UserData'); %get the set of times |
---|
3680 | % filebase=get(handles.RootName,'String'); |
---|
3681 | % %grid |
---|
3682 | % gridname='';%default ='noFile use default' |
---|
3683 | % gridflag='n';%default |
---|
3684 | % test_grid=get(handles.browse_gridciv2,'Value'); |
---|
3685 | % nbslice_grid=[]; |
---|
3686 | % if test_grid |
---|
3687 | % gridname=get(handles.grid_civ2,'String'); |
---|
3688 | % if numel(gridname)>4 && isequal(gridname(end-3:end),'grid') |
---|
3689 | % nbslice_grid=str2num(gridname(1:end-4)); % |
---|
3690 | % if ~isempty(nbslice_grid) |
---|
3691 | % gridflag='y'; |
---|
3692 | % end |
---|
3693 | % elseif exist(gridname,'file') |
---|
3694 | % gridflag='y'; |
---|
3695 | % else |
---|
3696 | % msgbox_uvmat('ERROR',['input grid file ' gridname ' not found']) |
---|
3697 | % return |
---|
3698 | % end |
---|
3699 | % end |
---|
3700 | % sizcell=size(filecell_2); |
---|
3701 | % nbfield=sizcell(1); |
---|
3702 | % nbslice=sizcell(2); |
---|
3703 | % |
---|
3704 | % %main loop |
---|
3705 | % icount=0; |
---|
3706 | % for ifile=1:nbfield |
---|
3707 | % for j=1:nbslice |
---|
3708 | % icount=icount+1; |
---|
3709 | % barlength=0.188*icount/(nbfield*nbslice); |
---|
3710 | % set(handles.waitbar_civ2,'Position',[0.946 0.407-barlength 0.03 barlength]) |
---|
3711 | % drawnow |
---|
3712 | % filename_ima_2=cell2mat(filecell_2(ifile,j)); |
---|
3713 | % filename_ima_2([end-3:end])=[];%remove .png extension |
---|
3714 | % filename_ima_3=cell2mat(filecell_3(ifile,j)); |
---|
3715 | % filename_ima_3([end-3:end])=[];%remove .png extension |
---|
3716 | % filename_cmx=cell2mat(filecell_nc2(ifile,j));%output netcdf file |
---|
3717 | % filename_cmx([end-1:end])=[ 'cm'];%name of cmx file |
---|
3718 | % filename_cmx=[filename_cmx 'x']; |
---|
3719 | % namelog=[filename_cmx([1:end-3]) 'log']; |
---|
3720 | % if size(time,1)>=num2(ifile) & size(time,2)>=num_b(j) |
---|
3721 | % Dt=num2str(time(num2(ifile),num_b(j))-time(num1(ifile),num_a(j))); |
---|
3722 | % if isequal(Dt,'0') |
---|
3723 | % Dt='1' ;%case of 'displacement' mode |
---|
3724 | % end |
---|
3725 | % T0=num2str((time(num2(ifile),num_b(j))+time(num1(ifile),num_a(j)))/2); |
---|
3726 | % else |
---|
3727 | % Dt='1'; |
---|
3728 | % T0='0'; |
---|
3729 | % end |
---|
3730 | % term_a=num2stra(num_a(j),nom_type_nc); |
---|
3731 | % term_b=num2stra(num_b(j),nom_type_nc); |
---|
3732 | % filename_nc1=cell2mat(filecell_nc1(ifile,j)); |
---|
3733 | % filename_nc1([end-2:end])=[]; % remove '.nc' |
---|
3734 | % if test_grid && ~isempty(nbslice_grid) |
---|
3735 | % num1_grid=mod(num1(ifile)-1,nbslice_grid)+1; |
---|
3736 | % gridname=[filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
3737 | % if ~exist(gridname,'file') |
---|
3738 | % msgbox_uvmat('ERROR',['missing grid file ' gridname]) |
---|
3739 | % return |
---|
3740 | % end |
---|
3741 | % end |
---|
3742 | % test_mask=get(handles.get_mask_civ2,'Value'); |
---|
3743 | % if test_mask==0 |
---|
3744 | % maskname='noFile use default'; |
---|
3745 | % maskflag='n'; |
---|
3746 | % else |
---|
3747 | % maskdispl=get(handles.mask_civ2,'String'); |
---|
3748 | % maskbase=[filebase '_' maskdispl]; % |
---|
3749 | % nbslice_mask=str2num(maskdispl(1:end-4)); % |
---|
3750 | % num1_mask=mod(num1(ifile)-1,nbslice_mask)+1; |
---|
3751 | % maskname =name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
3752 | % if ~exist(maskname,'file') |
---|
3753 | % maskflag='y'; |
---|
3754 | % else |
---|
3755 | % maskname='noFile use default'; |
---|
3756 | % maskflag='n'; |
---|
3757 | % end |
---|
3758 | % end |
---|
3759 | % |
---|
3760 | % textcmx={'############## CMX file';... |
---|
3761 | % ['FirstImage ' filename_ima_2];... |
---|
3762 | % ['LastImage ' filename_ima_3];... |
---|
3763 | % 'XX' ;... |
---|
3764 | % ['Mask ' maskflag];... |
---|
3765 | % ['MaskName ' maskname];... |
---|
3766 | % ['ImageSize ' npx ' ' npy];... |
---|
3767 | % ['CorrelationBoxesSize ' ibx ' ' iby];... |
---|
3768 | % ['SearchBoxeSize ' ibx ' ' iby];... |
---|
3769 | % ['RO ' rho];... |
---|
3770 | % ['GridSpacing ' dx ' ' dy];... |
---|
3771 | % 'XX 1.0';... |
---|
3772 | % ['Dt_TO ' Dt ' ' T0];... |
---|
3773 | % ['PixCmXY ' pxcmx ' ' pxcmy];... |
---|
3774 | % 'XX 1';... |
---|
3775 | % ['ShiftXY 0 0'];... |
---|
3776 | % ['Grid ' gridflag];... |
---|
3777 | % ['GridName ' gridname];... |
---|
3778 | % 'XX 85';... |
---|
3779 | % 'XX 1.0';... |
---|
3780 | % 'XX 1.0';... |
---|
3781 | % 'Hart 1';... |
---|
3782 | % ['DecimalShift ' decimal];... |
---|
3783 | % ['Deformation ' deformation];... |
---|
3784 | % 'CorrelationMin 0';... |
---|
3785 | % 'IntensityMin 0';... |
---|
3786 | % 'SeuilImage n';... |
---|
3787 | % 'SeuilImageValues 0 4096';... |
---|
3788 | % ['ImageToUse ' term_a ' ' term_b];... % VERIFIER ? |
---|
3789 | % ['ImageUsedBefore ' filename_nc1]}; |
---|
3790 | % textout=char(textcmx); |
---|
3791 | % dlmwrite(filename_cmx,textout,''); |
---|
3792 | % s=-1; |
---|
3793 | % display(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]) |
---|
3794 | % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog ]); |
---|
3795 | % |
---|
3796 | % % if sge%dispatch computation on the cluster using interactive queue |
---|
3797 | % % [s,w] = unix(['qrsh -q fast.q ' civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']); |
---|
3798 | % % end |
---|
3799 | % % if s~=0 |
---|
3800 | % % eval(['!' civ2Bin ' -f ' filename_cmx ' > ' namelog]); |
---|
3801 | % % ['!' civ2Bin ' -f ' filename_cmx ' > ' namelog] |
---|
3802 | % % end |
---|
3803 | % end |
---|
3804 | % end |
---|
3805 | % % close(h) |
---|
3806 | |
---|
3807 | %------------------------------------------------------------------------ |
---|
3808 | % --- PATCH |
---|
3809 | function cmd_PATCH=RUN_PATCH(filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,test_interp) |
---|
3810 | %------------------------------------------------------------------------ |
---|
3811 | global patchBin patch_newBin |
---|
3812 | namelog=[filename_nc([1:end-3]) '_patch.log']; |
---|
3813 | if test_interp==0 |
---|
3814 | cmd_PATCH=[patchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ... |
---|
3815 | ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
3816 | else %nouveau programme patch |
---|
3817 | cmd_PATCH=[patch_newBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
3818 | ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
3819 | end |
---|
3820 | |
---|
3821 | %------------------------------------------------------------------------ |
---|
3822 | % --- STEREO Interp |
---|
3823 | function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
3824 | %------------------------------------------------------------------------ |
---|
3825 | namelog=[filename_nc([1:end-3]) '_stinterp.log']; |
---|
3826 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
3827 | ' -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 |
---|
3828 | |
---|
3829 | %------------------------------------------------------------------------ |
---|
3830 | % --- Executes on button press in CIV1. |
---|
3831 | function CIV1_Callback(hObject, eventdata, handles) |
---|
3832 | %------------------------------------------------------------------------ |
---|
3833 | val=get(handles.CIV1,'Value'); |
---|
3834 | if isequal(val,1) |
---|
3835 | enable_civ1(handles,'on') |
---|
3836 | enable_pair1(handles,'on') |
---|
3837 | else |
---|
3838 | enable_civ1(handles,'off') |
---|
3839 | end |
---|
3840 | find_netcpair_civ1(hObject, eventdata, handles); |
---|
3841 | |
---|
3842 | %------------------------------------------------------------------------ |
---|
3843 | % --- Executes on button press in FIX1. |
---|
3844 | function FIX1_Callback(hObject, eventdata, handles) |
---|
3845 | %------------------------------------------------------------------------ |
---|
3846 | enable_fix1(handles,get(handles.FIX1,'Value')) |
---|
3847 | |
---|
3848 | %------------------------------------------------------------------------ |
---|
3849 | % --- Executes on button press in PATCH1. |
---|
3850 | function PATCH1_Callback(hObject, eventdata, handles) |
---|
3851 | %------------------------------------------------------------------------ |
---|
3852 | if get(handles.PATCH1,'Value')==1 |
---|
3853 | enable_patch1(handles) |
---|
3854 | else |
---|
3855 | desable_patch1(handles) |
---|
3856 | end |
---|
3857 | |
---|
3858 | %------------------------------------------------------------------------ |
---|
3859 | % --- Executes on button press in CIV2. |
---|
3860 | function CIV2_Callback(hObject, eventdata, handles) |
---|
3861 | %------------------------------------------------------------------------ |
---|
3862 | state=get(handles.CIV2,'Value'); |
---|
3863 | enable_civ2(handles,state) |
---|
3864 | if state |
---|
3865 | find_netcpair_civ2(hObject, eventdata, handles) |
---|
3866 | enable_pair1(handles,'on') |
---|
3867 | end |
---|
3868 | |
---|
3869 | %------------------------------------------------------------------------ |
---|
3870 | % --- Executes on button press in FIX2. |
---|
3871 | function FIX2_Callback(hObject, eventdata, handles) |
---|
3872 | %------------------------------------------------------------------------ |
---|
3873 | if get(handles.FIX2,'Value')==1 |
---|
3874 | enable_fix2(handles) |
---|
3875 | if get(handles.CIV2,'Value')==0 |
---|
3876 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
3877 | end |
---|
3878 | else |
---|
3879 | desable_fix2(handles) |
---|
3880 | end |
---|
3881 | |
---|
3882 | %------------------------------------------------------------------------ |
---|
3883 | % --- Executes on button press in PATCH2. |
---|
3884 | function PATCH2_Callback(hObject, eventdata, handles) |
---|
3885 | %------------------------------------------------------------------------ |
---|
3886 | if get(handles.PATCH2,'Value')==1 |
---|
3887 | enable_patch2(handles) |
---|
3888 | if get(handles.CIV2,'Value')==0 |
---|
3889 | find_netcpair_civ2(hObject, eventdata, handles) % select the available netcdf files |
---|
3890 | end |
---|
3891 | else |
---|
3892 | desable_patch2(handles) |
---|
3893 | end |
---|
3894 | |
---|
3895 | %------------------------------------------------------------------------ |
---|
3896 | function first_i_Callback(hObject, eventdata, handles) |
---|
3897 | %------------------------------------------------------------------------ |
---|
3898 | % last_i_Callback(hObject, eventdata, handles) |
---|
3899 | first_i=str2num(get(handles.first_i,'String')); |
---|
3900 | % last_i=str2num(get(handles.last_i,'String')); |
---|
3901 | % ref_i=ceil((first_i+last_i)/2); |
---|
3902 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
3903 | set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
3904 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3905 | |
---|
3906 | %------------------------------------------------------------------------ |
---|
3907 | function first_j_Callback(hObject, eventdata, handles) |
---|
3908 | %------------------------------------------------------------------------ |
---|
3909 | first_j=str2num(get(handles.first_j,'String')); |
---|
3910 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
3911 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3912 | |
---|
3913 | %------------------------------------------------------------------------ |
---|
3914 | % --- Executes on button press in calcul_search: determine the search range isx,isy |
---|
3915 | function calcul_search_Callback(hObject, eventdata, handles) |
---|
3916 | %------------------------------------------------------------------------ |
---|
3917 | %determine pair numbers |
---|
3918 | list_pair=get(handles.list_pair_civ1,'String');%get the menu of image pairs |
---|
3919 | index=get(handles.list_pair_civ1,'Value'); |
---|
3920 | displ_num=get(handles.list_pair_civ1,'UserData'); |
---|
3921 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
3922 | pxcm_xy=get(handles.calcul_search,'UserData'); |
---|
3923 | pxcmx=pxcm_xy(1); |
---|
3924 | pxcmy=pxcm_xy(2); |
---|
3925 | mode_list=get(handles.mode,'String'); |
---|
3926 | mode_value=get(handles.mode,'Value'); |
---|
3927 | mode=mode_list{mode_value}; |
---|
3928 | if isequal (mode, 'series(Di)' ) |
---|
3929 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
3930 | num1=ref_i-floor(index/2);% first image numbers |
---|
3931 | num2=ref_i+ceil(index/2); |
---|
3932 | num_a=1; |
---|
3933 | num_b=1; |
---|
3934 | elseif isequal (mode, 'series(Dj)') |
---|
3935 | num1=1; |
---|
3936 | num2=1; |
---|
3937 | ref_j=str2num(get(handles.ref_j,'String')); |
---|
3938 | num_a=ref_j-floor(index/2);% first image numbers |
---|
3939 | num_b=ref_j+ceil(index/2); |
---|
3940 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
3941 | ref_i=str2num(get(handles.ref_i,'String')); |
---|
3942 | num1=ref_i; |
---|
3943 | num2=ref_i; |
---|
3944 | num_a=displ_num(1,index); |
---|
3945 | num_b=displ_num(2,index); |
---|
3946 | end |
---|
3947 | dt=time(num2,num_b)-time(num1,num_a); |
---|
3948 | ibx=str2num(get(handles.ibx,'String')); |
---|
3949 | iby=str2num(get(handles.iby,'String')); |
---|
3950 | umin=dt*pxcmx*str2num(get(handles.umin,'String')); |
---|
3951 | umax=dt*pxcmx*str2num(get(handles.umax,'String')); |
---|
3952 | vmin=dt*pxcmy*str2num(get(handles.vmin,'String')); |
---|
3953 | vmax=dt*pxcmy*str2num(get(handles.vmax,'String')); |
---|
3954 | shiftx=round((umin+umax)/2); |
---|
3955 | shifty=round((vmin+vmax)/2); |
---|
3956 | isx=(umax+2-shiftx)*2+ibx; |
---|
3957 | isx=2*ceil(isx/2)+1; |
---|
3958 | isy=(vmax+2-shifty)*2+iby; |
---|
3959 | isy=2*ceil(isy/2)+1; |
---|
3960 | set(handles.shiftx,'String',num2str(shiftx)); |
---|
3961 | set(handles.shifty,'String',num2str(shifty)); |
---|
3962 | set(handles.isx,'String',num2str(isx)); |
---|
3963 | set(handles.isy,'String',num2str(isy)); |
---|
3964 | |
---|
3965 | %------------------------------------------------------------------------ |
---|
3966 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
3967 | function subdir_civ1_Callback(hObject, eventdata, handles) |
---|
3968 | %------------------------------------------------------------------------ |
---|
3969 | subdir=get(handles.subdir_civ1,'String'); |
---|
3970 | set(handles.subdir_civ2,'String',subdir); |
---|
3971 | if get(handles.CIV1,'Value')==0 |
---|
3972 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
3973 | end |
---|
3974 | |
---|
3975 | %------------------------------------------------------------------------ |
---|
3976 | % --- Executes on carriage return on the subdir civ1 edit window |
---|
3977 | function subdir_civ2_Callback(hObject, eventdata, handles) |
---|
3978 | %------------------------------------------------------------------------ |
---|
3979 | %update the list of available pairs from netcdf files in the new directory |
---|
3980 | if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0 |
---|
3981 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
3982 | end |
---|
3983 | |
---|
3984 | %------------------------------------------------------------------------ |
---|
3985 | % --- Executes on button press in get_mask_civ1. |
---|
3986 | function get_mask_civ1_Callback(hObject, eventdata, handles) |
---|
3987 | %------------------------------------------------------------------------ |
---|
3988 | maskval=get(handles.get_mask_civ1,'Value'); |
---|
3989 | if isequal(maskval,0) |
---|
3990 | set(handles.mask_civ1,'String','') |
---|
3991 | else |
---|
3992 | mask_displ='no mask'; %default |
---|
3993 | filebase=get(handles.RootName,'String'); |
---|
3994 | [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
3995 | if isequal(flag_mask,1) |
---|
3996 | mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
3997 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3998 | common_path=fileparts(filebase); |
---|
3999 | filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
4000 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
4001 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
4002 | mask_displ='no mask'; |
---|
4003 | end |
---|
4004 | end |
---|
4005 | if isequal(mask_displ,'no mask') |
---|
4006 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4007 | {'*.png', ' (*.png)'; |
---|
4008 | '*.png', '.png files '; ... |
---|
4009 | '*.*', 'All Files (*.*)'}, ... |
---|
4010 | 'Pick a mask file *.png',filebase); |
---|
4011 | mask_displ=fullfile(PathName,FileName); |
---|
4012 | if ~exist(mask_displ,'file') |
---|
4013 | mask_displ='no mask'; |
---|
4014 | end |
---|
4015 | end |
---|
4016 | if isequal(mask_displ,'no mask') |
---|
4017 | set(handles.get_mask_civ1,'Value',0) |
---|
4018 | set(handles.get_mask_fix1,'Value',0) |
---|
4019 | set(handles.get_mask_civ2,'Value',0) |
---|
4020 | set(handles.get_mask_fix2,'Value',0) |
---|
4021 | else |
---|
4022 | set(handles.get_mask_fix1,'Value',1) |
---|
4023 | set(handles.get_mask_fix2,'Value',1) |
---|
4024 | end |
---|
4025 | set(handles.mask_civ1,'String',mask_displ) |
---|
4026 | set(handles.mask_fix1,'String',mask_displ) |
---|
4027 | set(handles.mask_civ2,'String',mask_displ) |
---|
4028 | set(handles.mask_fix2,'String',mask_displ) |
---|
4029 | end |
---|
4030 | |
---|
4031 | %------------------------------------------------------------------------ |
---|
4032 | % --- Executes on button press in get_mask_fix1. |
---|
4033 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
4034 | %------------------------------------------------------------------------ |
---|
4035 | maskval=get(handles.get_mask_fix1,'Value'); |
---|
4036 | if isequal(maskval,0) |
---|
4037 | set(handles.mask_fix1,'String','') |
---|
4038 | else |
---|
4039 | mask_displ='no mask'; %default |
---|
4040 | filebase=get(handles.RootName,'String'); |
---|
4041 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
4042 | if isequal(flag_mask,1) |
---|
4043 | mask_displ=[num2str(nbslice) 'mask']; |
---|
4044 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
4045 | filebase_a=get(handles.RootName_1,'String'); |
---|
4046 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
4047 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
4048 | mask_displ='no mask'; |
---|
4049 | end |
---|
4050 | end |
---|
4051 | if isequal(mask_displ,'no mask') |
---|
4052 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4053 | {'*.png', ' (*.png)'; |
---|
4054 | '*.png', '.png files '; ... |
---|
4055 | '*.*', 'All Files (*.*)'}, ... |
---|
4056 | 'Pick a mask file *.png',filebase); |
---|
4057 | mask_displ=fullfile(PathName,FileName); |
---|
4058 | if ~exist(mask_displ,'file') |
---|
4059 | mask_displ='no mask'; |
---|
4060 | end |
---|
4061 | end |
---|
4062 | if isequal(mask_displ,'no mask') |
---|
4063 | set(handles.get_mask_fix1,'Value',0) |
---|
4064 | set(handles.get_mask_civ2,'Value',0) |
---|
4065 | set(handles.get_mask_fix2,'Value',0) |
---|
4066 | else |
---|
4067 | %set(handles.get_mask_civ2,'Value',1) |
---|
4068 | set(handles.get_mask_fix2,'Value',1) |
---|
4069 | end |
---|
4070 | set(handles.mask_fix1,'String',mask_displ) |
---|
4071 | set(handles.mask_civ2,'String',mask_displ) |
---|
4072 | set(handles.mask_fix2,'String',mask_displ) |
---|
4073 | end |
---|
4074 | |
---|
4075 | %------------------------------------------------------------------------ |
---|
4076 | % --- Executes on button press in get_mask_civ2. |
---|
4077 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
4078 | %------------------------------------------------------------------------ |
---|
4079 | maskval=get(handles.get_mask_civ2,'Value'); |
---|
4080 | if isequal(maskval,0) |
---|
4081 | set(handles.mask_civ2,'String','') |
---|
4082 | else |
---|
4083 | mask_displ='no mask'; %default |
---|
4084 | filebase=get(handles.RootName,'String'); |
---|
4085 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
4086 | if isequal(flag_mask,1) |
---|
4087 | mask_displ=[num2str(nbslice) 'mask']; |
---|
4088 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
4089 | filebase_a=get(handles.RootName_1,'String'); |
---|
4090 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
4091 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
4092 | mask_displ='no mask'; |
---|
4093 | end |
---|
4094 | end |
---|
4095 | if isequal(mask_displ,'no mask') |
---|
4096 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4097 | {'*.png', ' (*.png)'; |
---|
4098 | '*.png', '.png files '; ... |
---|
4099 | '*.*', 'All Files (*.*)'}, ... |
---|
4100 | 'Pick a mask file *.png',filebase); |
---|
4101 | mask_displ=fullfile(PathName,FileName); |
---|
4102 | if ~exist(mask_displ,'file') |
---|
4103 | mask_displ='no mask'; |
---|
4104 | end |
---|
4105 | end |
---|
4106 | if isequal(mask_displ,'no mask') |
---|
4107 | set(handles.get_mask_civ2,'Value',0) |
---|
4108 | set(handles.get_mask_fix2,'Value',0) |
---|
4109 | else |
---|
4110 | set(handles.get_mask_fix2,'Value',1) |
---|
4111 | end |
---|
4112 | set(handles.mask_civ2,'String',mask_displ) |
---|
4113 | set(handles.mask_fix2,'String',mask_displ) |
---|
4114 | end |
---|
4115 | |
---|
4116 | %------------------------------------------------------------------------ |
---|
4117 | % --- Executes on button press in get_mask_fix2. |
---|
4118 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
4119 | %------------------------------------------------------------------------ |
---|
4120 | maskval=get(handles.get_mask_fix2,'Value'); |
---|
4121 | if isequal(maskval,0) |
---|
4122 | set(handles.mask_fix2,'String','') |
---|
4123 | else |
---|
4124 | mask_displ='no mask'; %default |
---|
4125 | filebase=get(handles.RootName,'String'); |
---|
4126 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
4127 | if isequal(flag_mask,1) |
---|
4128 | mask_displ=[num2str(nbslice) 'mask']; |
---|
4129 | elseif get(handles.compare,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
4130 | filebase_a=get(handles.RootName_1,'String'); |
---|
4131 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
4132 | if isequal(flag_mask_a,0) | ~isequal(nbslice_a,nbslice) |
---|
4133 | mask_displ='no mask'; |
---|
4134 | end |
---|
4135 | end |
---|
4136 | if isequal(mask_displ,'no mask') |
---|
4137 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4138 | {'*.png', ' (*.png)'; |
---|
4139 | '*.png', '.png files '; ... |
---|
4140 | '*.*', 'All Files (*.*)'}, ... |
---|
4141 | 'Pick a mask file *.png',filebase); |
---|
4142 | mask_displ=fullfile(PathName,FileName); |
---|
4143 | if ~exist(mask_displ,'file') |
---|
4144 | mask_displ='no mask'; |
---|
4145 | end |
---|
4146 | end |
---|
4147 | if isequal(mask_displ,'no mask') |
---|
4148 | set(handles.get_mask_fix2,'Value',0) |
---|
4149 | end |
---|
4150 | set(handles.mask_fix2,'String',mask_displ) |
---|
4151 | end |
---|
4152 | |
---|
4153 | %------------------------------------------------------------------------ |
---|
4154 | % --- function called to look for mask files |
---|
4155 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
4156 | %------------------------------------------------------------------------ |
---|
4157 | %detect mask files, images with appropriate file base |
---|
4158 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
4159 | %flag_mask=1 indicates detection |
---|
4160 | |
---|
4161 | flag_mask=0;%default |
---|
4162 | nbslice=1; |
---|
4163 | |
---|
4164 | % subdir=get(handles.subdir_civ1,'String'); |
---|
4165 | [Path,Name]=fileparts(filebase); |
---|
4166 | if ~isdir(Path) |
---|
4167 | msgbox_uvmat('ERROR','no path for input files') |
---|
4168 | return |
---|
4169 | end |
---|
4170 | currentdir=pwd; |
---|
4171 | cd(Path);%move in the dir of the root name filebase |
---|
4172 | maskfiles=dir([Name '_*mask_*.png']);%look for mask files |
---|
4173 | cd(currentdir);%come back to the current working directory |
---|
4174 | if ~isempty(maskfiles) |
---|
4175 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
4176 | % else |
---|
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('mask',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 mask file ' Name ext ' found in ' Path2]) |
---|
4192 | return |
---|
4193 | nbslice=1; |
---|
4194 | end |
---|
4195 | end |
---|
4196 | |
---|
4197 | %------------------------------------------------------------------------ |
---|
4198 | % --- function called to look for grid files |
---|
4199 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
4200 | %------------------------------------------------------------------------ |
---|
4201 | flag_mask=0;%default |
---|
4202 | nbslice=1; |
---|
4203 | [Path,Name]=fileparts(filebase); |
---|
4204 | currentdir=pwd; |
---|
4205 | cd(Path);%move in the dir of the root name filebase |
---|
4206 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
4207 | cd(currentdir);%come back to the current working directory |
---|
4208 | if ~isempty(maskfiles) |
---|
4209 | flag_mask=1; |
---|
4210 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
4211 | [Path2,Name,ext]=fileparts(maskname); |
---|
4212 | Namedouble=double(Name); |
---|
4213 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
4214 | ind_mask=findstr('grid',Name); |
---|
4215 | i=ind_mask-1; |
---|
4216 | while val(i)==0 & i>0 |
---|
4217 | i=i-1; |
---|
4218 | end |
---|
4219 | nbslice=str2num(Name(i+1:ind_mask-1)); |
---|
4220 | if ~isequal(nbslice,[]) & Name(i)=='_' |
---|
4221 | flag_mask=1; |
---|
4222 | else |
---|
4223 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
4224 | return |
---|
4225 | nbslice=1; |
---|
4226 | end |
---|
4227 | end |
---|
4228 | |
---|
4229 | %------------------------------------------------------------------------ |
---|
4230 | % --- transform numbers to letters |
---|
4231 | function str=num2stra(num,nom_type); |
---|
4232 | %------------------------------------------------------------------------ |
---|
4233 | if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD') |
---|
4234 | str=char(96+num); |
---|
4235 | elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')... |
---|
4236 | |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none') |
---|
4237 | str=''; |
---|
4238 | else |
---|
4239 | str=num2str(num); |
---|
4240 | end |
---|
4241 | |
---|
4242 | %------------------------------------------------------------------------ |
---|
4243 | function mask_civ1_Callback(hObject, eventdata, handles) |
---|
4244 | %------------------------------------------------------------------------ |
---|
4245 | set(handles.mask_civ1,'UserData',[]) |
---|
4246 | set(handles.mask_civ1,'String','') |
---|
4247 | |
---|
4248 | %------------------------------------------------------------------------ |
---|
4249 | function mask_civ2_Callback(hObject, eventdata, handles) |
---|
4250 | %------------------------------------------------------------------------ |
---|
4251 | set(handles.mask_civ2,'UserData',[]) |
---|
4252 | set(handles.mask_civ2,'String','') |
---|
4253 | |
---|
4254 | %------------------------------------------------------------------------ |
---|
4255 | function mask_fix1_Callback(hObject, eventdata, handles) |
---|
4256 | %------------------------------------------------------------------------ |
---|
4257 | set(handles.mask_fix1,'UserData',[]) |
---|
4258 | set(handles.mask_fix1,'String','') |
---|
4259 | |
---|
4260 | %------------------------------------------------------------------------ |
---|
4261 | function mask_fix2_Callback(hObject, eventdata, handles) |
---|
4262 | %------------------------------------------------------------------------ |
---|
4263 | set(handles.mask_fix2,'UserData',[]) |
---|
4264 | set(handles.mask_fix2,'String','') |
---|
4265 | |
---|
4266 | %------------------------------------------------------------------------ |
---|
4267 | % --- Executes on button press in list_subdir_civ1. |
---|
4268 | function list_subdir_civ1_Callback(hObject, eventdata, handles) |
---|
4269 | %------------------------------------------------------------------------ |
---|
4270 | list_subdir_civ1=get(handles.list_subdir_civ1,'String'); |
---|
4271 | val=get(handles.list_subdir_civ1,'Value'); |
---|
4272 | if val>1 |
---|
4273 | subdir=list_subdir_civ1{val}; |
---|
4274 | set(handles.subdir_civ1,'String',subdir); |
---|
4275 | set(handles.list_subdir_civ1,'Value',1); |
---|
4276 | end |
---|
4277 | |
---|
4278 | %------------------------------------------------------------------------ |
---|
4279 | % --- Executes on button press in list_subdir_civ2. |
---|
4280 | function list_subdir_civ2_Callback(hObject, eventdata, handles) |
---|
4281 | %------------------------------------------------------------------------ |
---|
4282 | list_subdir_civ2=get(handles.list_subdir_civ2,'String'); |
---|
4283 | val=get(handles.list_subdir_civ2,'Value'); |
---|
4284 | if val>1 |
---|
4285 | subdir=list_subdir_civ2{val}; |
---|
4286 | set(handles.subdir_civ2,'String',subdir); |
---|
4287 | set(handles.list_subdir_civ2,'Value',1); |
---|
4288 | end |
---|
4289 | |
---|
4290 | %------------------------------------------------------------------------ |
---|
4291 | % --- Executes on button press in browse_gridciv1. |
---|
4292 | function browse_gridciv1_Callback(hObject, eventdata, handles) |
---|
4293 | %------------------------------------------------------------------------ |
---|
4294 | value=get(handles.browse_gridciv1,'Value'); |
---|
4295 | testgrid=0; |
---|
4296 | if value |
---|
4297 | filebase=get(handles.RootName,'String'); |
---|
4298 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
4299 | if isequal(flag_grid,1) |
---|
4300 | filegrid=[num2str(nbslice) 'grid']; |
---|
4301 | testgrid=1; |
---|
4302 | else |
---|
4303 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4304 | {'*.grid', ' (*.grid)'; |
---|
4305 | '*.grid', '.grid files '; ... |
---|
4306 | '*.*', 'All Files (*.*)'}, ... |
---|
4307 | 'Pick a file',filebase); |
---|
4308 | filegrid=fullfile(PathName,FileName); |
---|
4309 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
4310 | testgrid=1; |
---|
4311 | end |
---|
4312 | end |
---|
4313 | end |
---|
4314 | if testgrid |
---|
4315 | set(handles.browse_gridciv2,'Value',1) |
---|
4316 | set(handles.get_gridpatch1,'Value',1) |
---|
4317 | set(handles.get_gridpatch2,'Value',1) |
---|
4318 | set(handles.dx_civ1,'Visible','off'); |
---|
4319 | set(handles.dy_civ1,'Visible','off'); |
---|
4320 | set(handles.dx_civ2,'Visible','off'); |
---|
4321 | set(handles.dy_civ2,'Visible','off'); |
---|
4322 | set(handles.grid_civ1,'String',filegrid) |
---|
4323 | set(handles.grid_patch1,'String',filegrid) |
---|
4324 | set(handles.grid_civ2,'String',filegrid) |
---|
4325 | set(handles.grid_patch2,'String',filegrid) |
---|
4326 | else |
---|
4327 | set(handles.browse_gridciv1,'Value',0); |
---|
4328 | set(handles.browse_gridciv2,'Value',0); |
---|
4329 | set(handles.get_gridpatch1,'Value',0) |
---|
4330 | set(handles.get_gridpatch2,'Value',0) |
---|
4331 | set(handles.dx_civ1,'Visible','on'); |
---|
4332 | set(handles.dy_civ1,'Visible','on'); |
---|
4333 | set(handles.dx_civ2,'Visible','on'); |
---|
4334 | set(handles.dy_civ2,'Visible','on'); |
---|
4335 | set(handles.grid_civ1,'String','') |
---|
4336 | set(handles.grid_patch1,'String','') |
---|
4337 | set(handles.grid_civ2,'String','') |
---|
4338 | set(handles.grid_patch2,'String','') |
---|
4339 | end |
---|
4340 | |
---|
4341 | %------------------------------------------------------------------------ |
---|
4342 | % --- Executes on button press in browse_gridciv1. |
---|
4343 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
4344 | %------------------------------------------------------------------------ |
---|
4345 | value=get(handles.browse_gridciv2,'Value'); |
---|
4346 | if value |
---|
4347 | filebase=get(handles.RootName,'String'); |
---|
4348 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
4349 | if isequal(flag_grid,1) |
---|
4350 | mask_displ=[num2str(nbslice) 'grid']; |
---|
4351 | set(handles.grid_civ2,'String',mask_displ) |
---|
4352 | set(handles.dx_civ2,'Visible','off'); |
---|
4353 | set(handles.dy_civ2,'Visible','off'); |
---|
4354 | else |
---|
4355 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4356 | {'*.grid', ' (*.grid)'; |
---|
4357 | '*.grid', '.grid files '; ... |
---|
4358 | '*.*', 'All Files (*.*)'}, ... |
---|
4359 | 'Pick a file',filebase); |
---|
4360 | filegrid=fullfile(PathName,FileName); |
---|
4361 | if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') |
---|
4362 | set(handles.browse_gridciv2,'Value',0); |
---|
4363 | set(handles.grid_civ2,'string',''); |
---|
4364 | set(handles.dx_civ2,'Visible','on'); |
---|
4365 | set(handles.dy_civ2,'Visible','on'); |
---|
4366 | set(handles.grid_civ2,'string',''); |
---|
4367 | else |
---|
4368 | set(handles.grid_civ2,'string',filegrid); |
---|
4369 | set(handles.dx_civ2,'Visible','off'); |
---|
4370 | set(handles.dy_civ2,'Visible','off'); |
---|
4371 | set(handles.grid_civ2,'string',filegrid); |
---|
4372 | end |
---|
4373 | end |
---|
4374 | else |
---|
4375 | set(handles.grid_civ2,'string',''); |
---|
4376 | set(handles.dx_civ2,'Visible','on'); |
---|
4377 | set(handles.dy_civ2,'Visible','on'); |
---|
4378 | set(handles.grid_civ2,'string',''); |
---|
4379 | end |
---|
4380 | |
---|
4381 | % % --- Executes on button press in browse_gridciv2. |
---|
4382 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
4383 | % |
---|
4384 | % filebase=get(handles.RootName,'String'); |
---|
4385 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
4386 | % {'*.grid', ' (*.grid)'; |
---|
4387 | % '*.grid', '.grid files '; ... |
---|
4388 | % '*.*', 'All Files (*.*)'}, ... |
---|
4389 | % 'Pick a file',filebase); |
---|
4390 | % filegrid=fullfile(PathName,FileName); |
---|
4391 | % set(handles.grid_civ2,'string',filegrid); |
---|
4392 | % set(handles.dx_civ2,'String',' '); |
---|
4393 | % set(handles.dy_civ2,'String',' '); |
---|
4394 | % % set(handles.grid_patch2,'string',filegrid); |
---|
4395 | |
---|
4396 | % --- Executes on button press in get_gridpatch1. |
---|
4397 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
4398 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
4399 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
4400 | % handles structure with handles and user data (see GUIDATA) |
---|
4401 | |
---|
4402 | filebase=get(handles.RootName,'String'); |
---|
4403 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4404 | {'*.grid', ' (*.grid)'; |
---|
4405 | '*.grid', '.grid files '; ... |
---|
4406 | '*.*', 'All Files (*.*)'}, ... |
---|
4407 | 'Pick a file',filebase); |
---|
4408 | filegrid=fullfile(PathName,FileName); |
---|
4409 | set(handles.grid_patch1,'string',filegrid); |
---|
4410 | % set(handles.grid_patch2,'string',filegrid |
---|
4411 | |
---|
4412 | %------------------------------------------------------------------------ |
---|
4413 | % --- Executes on button press in get_gridpatch2. |
---|
4414 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
4415 | %------------------------------------------------------------------------ |
---|
4416 | |
---|
4417 | %------------------------------------------------------------------------ |
---|
4418 | function enable_civ1(handles,state) |
---|
4419 | %------------------------------------------------------------------------ |
---|
4420 | if isequal(state,0) |
---|
4421 | state='off'; |
---|
4422 | end |
---|
4423 | if isequal(state,1) |
---|
4424 | state='on'; |
---|
4425 | end |
---|
4426 | if isequal(state,'on') |
---|
4427 | set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
4428 | set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
4429 | set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
4430 | else |
---|
4431 | set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4432 | set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4433 | set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4434 | end |
---|
4435 | set(handles.ibx,'Visible',state) |
---|
4436 | set(handles.iby,'Visible',state) |
---|
4437 | set(handles.isx,'Visible',state) |
---|
4438 | set(handles.isy,'Visible',state) |
---|
4439 | set(handles.shiftx,'Visible',state) |
---|
4440 | set(handles.shifty,'Visible',state) |
---|
4441 | set(handles.rho,'Visible',state) |
---|
4442 | set(handles.dx_civ1,'Visible',state) |
---|
4443 | set(handles.dy_civ1,'Visible',state) |
---|
4444 | set(handles.calcul_search,'Visible',state) |
---|
4445 | set(handles.u_text,'Visible',state) |
---|
4446 | set(handles.v_text,'Visible',state) |
---|
4447 | set(handles.min,'Visible',state) |
---|
4448 | set(handles.max,'Visible',state) |
---|
4449 | set(handles.umin,'Visible',state) |
---|
4450 | set(handles.umax,'Visible',state) |
---|
4451 | set(handles.vmin,'Visible',state) |
---|
4452 | set(handles.vmax,'Visible',state) |
---|
4453 | set(handles.grid_civ1,'Visible',state) |
---|
4454 | set(handles.mask_civ1,'Visible',state) |
---|
4455 | set(handles.browse_gridciv1,'Visible',state) |
---|
4456 | set(handles.get_mask_civ1,'Visible',state) |
---|
4457 | set(handles.parameters,'Visible',state) |
---|
4458 | set(handles.grid,'Visible',state) |
---|
4459 | set(handles.dx_civ1,'Visible',state) |
---|
4460 | set(handles.dy_civ1,'Visible',state) |
---|
4461 | set(handles.ImaThreshold,'Visible',state) |
---|
4462 | if isequal(state,'off') |
---|
4463 | set(handles.MinIma,'Visible','off') |
---|
4464 | set(handles.MaxIma,'Visible','off') |
---|
4465 | set(handles.ImaThreshold,'Value',0) |
---|
4466 | end |
---|
4467 | set(handles.dx_civ1_title,'Visible',state) |
---|
4468 | set(handles.dy_civ1_title,'Visible',state) |
---|
4469 | set(handles.ImaThreshold_title,'Visible',state) |
---|
4470 | set(handles.ib_title,'Visible',state) |
---|
4471 | set(handles.is_title,'Visible',state) |
---|
4472 | set(handles.shift_title,'Visible',state) |
---|
4473 | set(handles.rho_title,'Visible',state) |
---|
4474 | |
---|
4475 | %------------------------------------------------------------------------ |
---|
4476 | function enable_fix1(handles,state) |
---|
4477 | %------------------------------------------------------------------------ |
---|
4478 | if isequal(state,0) |
---|
4479 | state='off'; |
---|
4480 | end |
---|
4481 | if isequal(state,1) |
---|
4482 | state='on'; |
---|
4483 | end |
---|
4484 | if isequal(state,'on') |
---|
4485 | set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
4486 | else |
---|
4487 | set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4488 | end |
---|
4489 | set(handles.REMOVE,'Visible',state) |
---|
4490 | set(handles.vec_Fmin2,'Visible',state) |
---|
4491 | set(handles.vec_F2,'Visible',state) |
---|
4492 | set(handles.vec_F3,'Visible',state) |
---|
4493 | set(handles.thresh_vecC,'Visible',state) |
---|
4494 | set(handles.thresh_vecC_title,'Visible',state) |
---|
4495 | set(handles.thresh_vel,'Visible',state) |
---|
4496 | set(handles.thresh_vel_text,'Visible',state) |
---|
4497 | set(handles.mask_fix1,'Visible',state) |
---|
4498 | set(handles.get_mask_fix1,'Visible',state) |
---|
4499 | set(handles.get_ref_fix1,'Visible',state) |
---|
4500 | set(handles.ref_fix1,'Visible',state) |
---|
4501 | set(handles.inf_sup1,'Visible',state) |
---|
4502 | set(handles.field_ref1,'Visible',state) |
---|
4503 | |
---|
4504 | %------------------------------------------------------------------------ |
---|
4505 | function enable_patch1(handles) |
---|
4506 | %------------------------------------------------------------------------ |
---|
4507 | global patch_newBin |
---|
4508 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
4509 | set(handles.rho_patch1,'Visible','on') |
---|
4510 | set(handles.rho_text1,'Visible','on') |
---|
4511 | set(handles.thresh_patch1,'Visible','on') |
---|
4512 | set(handles.thresh_text1,'Visible','on') |
---|
4513 | set(handles.subdomain_patch1,'Visible','on') |
---|
4514 | set(handles.subdomain_text1,'Visible','on') |
---|
4515 | set(handles.nx_patch1,'Visible','on') |
---|
4516 | set(handles.ny_patch1,'Visible','on') |
---|
4517 | set(handles.nx_patch1_title,'Visible','on') |
---|
4518 | set(handles.ny_patch1_title,'Visible','on') |
---|
4519 | if (~isequal(patch_newBin,[]) & ~isequal(patch_newBin,[])) |
---|
4520 | set(handles.test_interp,'Visible','on'); |
---|
4521 | end |
---|
4522 | set(handles.get_gridpatch1,'Visible','on') |
---|
4523 | set(handles.grid_patch1,'string','none'); |
---|
4524 | set(handles.grid_patch1,'Visible','on') |
---|
4525 | |
---|
4526 | %------------------------------------------------------------------------ |
---|
4527 | function desable_patch1(handles) |
---|
4528 | %------------------------------------------------------------------------ |
---|
4529 | set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4530 | set(handles.rho_patch1,'Visible','off') |
---|
4531 | set(handles.rho_text1,'Visible','off') |
---|
4532 | set(handles.thresh_patch1,'Visible','off') |
---|
4533 | set(handles.thresh_text1,'Visible','off') |
---|
4534 | set(handles.subdomain_patch1,'Visible','off') |
---|
4535 | set(handles.subdomain_text1,'Visible','off') |
---|
4536 | set(handles.nx_patch1,'Visible','off') |
---|
4537 | set(handles.ny_patch1,'Visible','off') |
---|
4538 | set(handles.nx_patch1_title,'Visible','off') |
---|
4539 | set(handles.ny_patch1_title,'Visible','off') |
---|
4540 | set(handles.test_interp,'Visible','off') |
---|
4541 | set(handles.get_gridpatch1,'Visible','off') |
---|
4542 | set(handles.grid_patch1,'Visible','off') |
---|
4543 | |
---|
4544 | %------------------------------------------------------------------------ |
---|
4545 | function enable_civ2(handles,state) |
---|
4546 | %------------------------------------------------------------------------ |
---|
4547 | if isequal(state,0) |
---|
4548 | state='off'; |
---|
4549 | end |
---|
4550 | if isequal(state,1) |
---|
4551 | state='on'; |
---|
4552 | end |
---|
4553 | if isequal(state,'on') |
---|
4554 | set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
4555 | set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
4556 | set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
4557 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
4558 | else |
---|
4559 | set(handles.frame_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4560 | set(handles.frame_para_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4561 | set(handles.frame_grid_civ2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4562 | set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4563 | end |
---|
4564 | set(handles.ibx_civ2,'Visible',state) |
---|
4565 | set(handles.iby_civ2,'Visible',state) |
---|
4566 | set(handles.decimal,'Visible',state) |
---|
4567 | set(handles.deformation,'Visible',state) |
---|
4568 | set(handles.rho_civ2,'Visible',state) |
---|
4569 | set(handles.dx_civ2,'Visible',state) |
---|
4570 | set(handles.dy_civ2,'Visible',state) |
---|
4571 | set(handles.browse_gridciv2,'Visible',state) |
---|
4572 | set(handles.get_mask_civ2,'Visible',state) |
---|
4573 | set(handles.parameters,'Visible',state) |
---|
4574 | set(handles.grid,'Visible',state) |
---|
4575 | set(handles.parameters_text,'Visible',state) |
---|
4576 | set(handles.grid_text,'Visible',state) |
---|
4577 | set(handles.grid_civ2,'Visible',state) |
---|
4578 | set(handles.mask_civ2,'Visible',state) |
---|
4579 | set(handles.dx_civ2_title,'Visible',state) |
---|
4580 | set(handles.dy_civ2_title,'Visible',state) |
---|
4581 | set(handles.ibx_civ2_text,'Visible',state) |
---|
4582 | set(handles.rho_civ2_title,'Visible',state) |
---|
4583 | set(handles.ImaThreshold2,'Visible',state) |
---|
4584 | set(handles.ImaThreshold_title2,'Visible',state) |
---|
4585 | if isequal(state,'off') |
---|
4586 | set(handles.MinIma2,'Visible','off') |
---|
4587 | set(handles.MaxIma2,'Visible','off') |
---|
4588 | set(handles.ImaThreshold2,'Value',0) |
---|
4589 | if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
4590 | set(handles.list_pair_civ2,'Visible','off') |
---|
4591 | set(handles.subdir_civ2,'Visible','off') |
---|
4592 | set(handles.subdir_civ2_text,'Visible','off') |
---|
4593 | set(handles.dt_unit_civ2,'Visible','off') |
---|
4594 | set(handles.ref_i_civ2,'Visible','off') |
---|
4595 | set(handles.i_ref_civ2_title,'Visible','off') |
---|
4596 | set(handles.j_ref_civ2_title,'Visible','off') |
---|
4597 | set(handles.ref_j_civ2,'Visible','off') |
---|
4598 | end |
---|
4599 | else |
---|
4600 | set(handles.list_pair_civ2,'Visible','on') |
---|
4601 | set(handles.subdir_civ2,'Visible','on') |
---|
4602 | set(handles.subdir_civ2_text,'Visible','on') |
---|
4603 | set(handles.dt_unit_civ2,'Visible','on') |
---|
4604 | set(handles.ref_i_civ2,'Visible','on') |
---|
4605 | set(handles.i_ref_civ2_title,'Visible','on') |
---|
4606 | set(handles.j_ref_civ2_title,'Visible','on') |
---|
4607 | set(handles.ref_j_civ2,'Visible','on') |
---|
4608 | end |
---|
4609 | set(handles.rho_civ2_title,'Visible',state) |
---|
4610 | |
---|
4611 | %------------------------------------------------------------------------ |
---|
4612 | function enable_fix2(handles) |
---|
4613 | %------------------------------------------------------------------------ |
---|
4614 | set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
4615 | set(handles.REMOVE2,'Visible','on') |
---|
4616 | set(handles.vec_Fmin2_2,'Visible','on') |
---|
4617 | set(handles.vec_F4,'Visible','on') |
---|
4618 | set(handles.vec_F3_2,'Visible','on') |
---|
4619 | set(handles.thresh_vec2C,'Visible','on') |
---|
4620 | set(handles.thresh_vec2C_text,'Visible','on') |
---|
4621 | set(handles.thresh_vel2,'Visible','on') |
---|
4622 | set(handles.thresh_vel2_text,'Visible','on') |
---|
4623 | set(handles.mask_fix2,'Visible','on') |
---|
4624 | set(handles.get_mask_fix2,'Visible','on') |
---|
4625 | set(handles.list_pair_civ2,'Visible','on') |
---|
4626 | set(handles.subdir_civ2,'Visible','on') |
---|
4627 | set(handles.subdir_civ2_text,'Visible','on') |
---|
4628 | set(handles.get_ref_fix2,'Visible','on') |
---|
4629 | set(handles.ref_fix2,'Visible','on') |
---|
4630 | set(handles.inf_sup2,'Visible','on') |
---|
4631 | set(handles.field_ref2,'Visible','on') |
---|
4632 | |
---|
4633 | %------------------------------------------------------------------------ |
---|
4634 | function desable_fix2(handles) |
---|
4635 | %------------------------------------------------------------------------ |
---|
4636 | set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4637 | set(handles.REMOVE2,'Visible','off') |
---|
4638 | set(handles.vec_Fmin2_2,'Visible','off') |
---|
4639 | set(handles.vec_F4,'Visible','off') |
---|
4640 | set(handles.vec_F3_2,'Visible','off') |
---|
4641 | set(handles.thresh_vec2C,'Visible','off') |
---|
4642 | set(handles.thresh_vec2C_text,'Visible','off') |
---|
4643 | set(handles.thresh_vel2,'Visible','off') |
---|
4644 | set(handles.thresh_vel2_text,'Visible','off') |
---|
4645 | set(handles.mask_fix2,'Visible','off') |
---|
4646 | set(handles.get_mask_fix2,'Visible','off') |
---|
4647 | set(handles.get_ref_fix2,'Visible','off') |
---|
4648 | set(handles.ref_fix2,'Visible','off') |
---|
4649 | set(handles.inf_sup2,'Visible','off') |
---|
4650 | set(handles.field_ref2,'Visible','off') |
---|
4651 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) |
---|
4652 | set(handles.list_pair_civ2,'Visible','off') |
---|
4653 | set(handles.subdir_civ2,'Visible','off') |
---|
4654 | set(handles.subdir_civ2_text,'Visible','off') |
---|
4655 | end |
---|
4656 | |
---|
4657 | %------------------------------------------------------------------------ |
---|
4658 | function enable_patch2(handles) |
---|
4659 | %------------------------------------------------------------------------ |
---|
4660 | set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
4661 | %set(handles.rho_patch2,'Visible','on') |
---|
4662 | set(handles.rho_text2,'Visible','on') |
---|
4663 | set(handles.thresh_patch2,'Visible','on') |
---|
4664 | set(handles.thresh_text2,'Visible','on') |
---|
4665 | set(handles.subdomain_patch2,'Visible','on') |
---|
4666 | set(handles.subdomain_text2,'Visible','on') |
---|
4667 | set(handles.nx_patch2,'Visible','on') |
---|
4668 | set(handles.ny_patch2,'Visible','on') |
---|
4669 | set(handles.nx_patch2_title,'Visible','on') |
---|
4670 | set(handles.ny_patch2_title,'Visible','on') |
---|
4671 | set(handles.get_gridpatch2,'Visible','on') |
---|
4672 | set(handles.grid_patch2,'Visible','on') |
---|
4673 | set(handles.list_pair_civ2,'Visible','on') |
---|
4674 | set(handles.subdir_civ2,'Visible','on') |
---|
4675 | set(handles.subdir_civ2_text,'Visible','on') |
---|
4676 | |
---|
4677 | %------------------------------------------------------------------------ |
---|
4678 | function desable_patch2(handles) |
---|
4679 | %------------------------------------------------------------------------ |
---|
4680 | set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4681 | set(handles.rho_patch2,'Visible','off') |
---|
4682 | set(handles.rho_text2,'Visible','off') |
---|
4683 | set(handles.thresh_patch2,'Visible','off') |
---|
4684 | set(handles.thresh_text2,'Visible','off') |
---|
4685 | set(handles.subdomain_patch2,'Visible','off') |
---|
4686 | set(handles.subdomain_text2,'Visible','off') |
---|
4687 | set(handles.nx_patch2,'Visible','off') |
---|
4688 | set(handles.ny_patch2,'Visible','off') |
---|
4689 | set(handles.nx_patch2_title,'Visible','off') |
---|
4690 | set(handles.ny_patch2_title,'Visible','off') |
---|
4691 | set(handles.get_gridpatch2,'Visible','off') |
---|
4692 | set(handles.grid_patch2,'Visible','off') |
---|
4693 | if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) |
---|
4694 | set(handles.list_pair_civ2,'Visible','off') |
---|
4695 | set(handles.subdir_civ2,'Visible','off') |
---|
4696 | set(handles.subdir_civ2_text,'Visible','off') |
---|
4697 | end |
---|
4698 | |
---|
4699 | %------------------------------------------------------------------------ |
---|
4700 | function enable_pair1(handles,state) |
---|
4701 | %------------------------------------------------------------------------ |
---|
4702 | set(handles.subdir_civ1,'Visible',state) |
---|
4703 | set(handles.list_subdir_civ1,'Visible',state) |
---|
4704 | set(handles.SUBDIR_CIV1_txt,'Visible',state) |
---|
4705 | set(handles.frame_subdirciv1,'Visible',state) |
---|
4706 | set(handles.list_pair_civ1,'Visible',state) |
---|
4707 | set(handles.PAIR_txt,'Visible',state) |
---|
4708 | %set(handles.dt_unit,'Visible',state) |
---|
4709 | set(handles.PAIR_frame,'Visible',state) |
---|
4710 | |
---|
4711 | %------------------------------------------------------------------------ |
---|
4712 | % --- Read the parameters for civ1 on the interface |
---|
4713 | function par=read_param_civ1(handles,file_ima) |
---|
4714 | %------------------------------------------------------------------------ |
---|
4715 | ibx_val=str2num(get(handles.ibx,'String')); |
---|
4716 | par.ibx=num2str(ibx_val); |
---|
4717 | iby_val=str2num(get(handles.iby,'String')); |
---|
4718 | par.iby=num2str(iby_val); |
---|
4719 | isx=get(handles.isx,'String'); |
---|
4720 | if isempty(str2num(isx)), isx='41'; set(handles.isx,'String','41'), end; %default |
---|
4721 | if str2num(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.isx,'String',num2str(ibx_val+8)); end |
---|
4722 | isy=get(handles.isy,'String'); |
---|
4723 | if isempty(str2num(isy)), isy='41'; set(handles.isy,'String','41'), end;%default |
---|
4724 | if str2num(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.isy,'String',num2str(iby_val+8)); end |
---|
4725 | par.isx=get(handles.isx,'String'); |
---|
4726 | par.isy=get(handles.isy,'String'); |
---|
4727 | par.shiftx=get(handles.shiftx,'String'); |
---|
4728 | par.shifty=get(handles.shifty,'String'); |
---|
4729 | if isempty(str2num(par.isx)) |
---|
4730 | par.isx='41';%default |
---|
4731 | set(handles.isx,'String','41'); |
---|
4732 | end |
---|
4733 | if isempty(str2num(par.isy)) |
---|
4734 | par.isy='41'; %default |
---|
4735 | set(handles.isy,'String','41'); |
---|
4736 | end |
---|
4737 | if isempty(str2num(par.shiftx)) |
---|
4738 | par.shiftx='0';%default |
---|
4739 | set(handles.shiftx,'String','0'); |
---|
4740 | end |
---|
4741 | if isempty(str2num(par.shifty)) |
---|
4742 | par.shifty='0'; %default |
---|
4743 | set(handles.shifty,'String','0'); |
---|
4744 | end |
---|
4745 | par.rho=get(handles.rho,'String'); |
---|
4746 | par.dx=get(handles.dx_civ1,'String'); |
---|
4747 | par.dy=get(handles.dy_civ1,'String'); |
---|
4748 | if isequal(str2num(par.dx),[]) |
---|
4749 | if isempty(get(handles.grid_civ1,'String')); |
---|
4750 | par.dx='0'; %just read by civ program, not used |
---|
4751 | else |
---|
4752 | par.dx='20';%default |
---|
4753 | set(handles.dx_civ1,'String','20'); |
---|
4754 | end |
---|
4755 | end |
---|
4756 | if isequal(str2num(par.dy),[]) |
---|
4757 | if isempty(get(handles.grid_civ1,'String')); |
---|
4758 | par.dy='0';%just read by civ program, not used |
---|
4759 | else |
---|
4760 | par.dy='20';%default |
---|
4761 | set(handles.dy_civ1_title,'String','20'); |
---|
4762 | end |
---|
4763 | end |
---|
4764 | par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
4765 | par.pxcmy='1'; |
---|
4766 | % end |
---|
4767 | A=imread(file_ima);%read the first image to get the size |
---|
4768 | sizim=size(A); |
---|
4769 | par.npx=num2str(sizim(2)); |
---|
4770 | par.npy=num2str(sizim(1)); |
---|
4771 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
4772 | par.gridname=get(handles.grid_civ1,'String'); |
---|
4773 | par.gridflag='y'; |
---|
4774 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
4775 | par.gridname='nogrid'; |
---|
4776 | par.gridflag='n'; |
---|
4777 | end |
---|
4778 | |
---|
4779 | %------------------------------------------------------------------------ |
---|
4780 | function par=read_param_civ2(handles,file_ima) |
---|
4781 | %------------------------------------------------------------------------ |
---|
4782 | par.ibx=get(handles.ibx_civ2,'String'); |
---|
4783 | par.iby=get(handles.iby_civ2,'String'); |
---|
4784 | par.rho=get(handles.rho_civ2,'String'); |
---|
4785 | par.decimal=int2str(get(handles.decimal,'Value')); |
---|
4786 | par.deformation=int2str(get(handles.deformation,'Value')); |
---|
4787 | par.dx=get(handles.dx_civ2,'String'); |
---|
4788 | par.dy=get(handles.dy_civ2,'String'); |
---|
4789 | if isequal(str2num(par.dx),[]) |
---|
4790 | if isempty(get(handles.grid_civ2,'String')); |
---|
4791 | par.dx='0'; %just read by civ program, not used |
---|
4792 | else |
---|
4793 | par.dx='20';%default |
---|
4794 | set(handles.dx_civ2,'String','20'); |
---|
4795 | end |
---|
4796 | end |
---|
4797 | if isequal(str2num(par.dy),[]) |
---|
4798 | if isempty(get(handles.grid_civ2,'String')); |
---|
4799 | par.dy='0';%just read by civ program, not used |
---|
4800 | else |
---|
4801 | par.dy='20';%default |
---|
4802 | set(handles.dy_civ2,'String','20'); |
---|
4803 | end |
---|
4804 | end |
---|
4805 | par.pxcmx='1'; |
---|
4806 | par.pxcmy='1'; |
---|
4807 | A=imread(file_ima);%read the first image to get the size |
---|
4808 | sizim=size(A); |
---|
4809 | par.npx=num2str(sizim(2)); |
---|
4810 | par.npy=num2str(sizim(1)); |
---|
4811 | time=get(handles.RootName,'UserData'); %get the set of times |
---|
4812 | par.gridname=get(handles.grid_civ2,'String'); |
---|
4813 | par.gridflag='y'; |
---|
4814 | if isequal(par.gridname,'')| isempty(par.gridname) |
---|
4815 | par.gridname='nogrid'; |
---|
4816 | par.gridflag='n'; |
---|
4817 | end |
---|
4818 | |
---|
4819 | %------------------------------------------------------------------------ |
---|
4820 | % --- CIV1 CIV1 CIV1 CIV1 |
---|
4821 | function cmd_CIV1=BATCH_CIV1(filename,namelog,par,handles,sparam) |
---|
4822 | %------------------------------------------------------------------------ |
---|
4823 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4824 | |
---|
4825 | %changes : filename_cmx -> filename ( no extension ) |
---|
4826 | |
---|
4827 | if isequal(par.Dt,'0') |
---|
4828 | par.Dt='1' ;%case of 'displacement' mode |
---|
4829 | end |
---|
4830 | % |
---|
4831 | % textcmx={'############## CMX file';... |
---|
4832 | % ['FirstImage ' par.filename_ima_a];... |
---|
4833 | % ['LastImage ' par.filename_ima_b];... |
---|
4834 | % 'XX' ;... |
---|
4835 | % ['Mask ' par.maskflag] ;... |
---|
4836 | % ['MaskName ' par.maskname];... |
---|
4837 | % ['ImageSize ' par.npx ' ' par.npy];... %VERIFIER CAS GENERAL ? |
---|
4838 | % ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... |
---|
4839 | % ['SearchBoxeSize ' par.isx ' ' par.isy];... |
---|
4840 | % ['RO ' par.rho];... |
---|
4841 | % ['GridSpacing ' par.dx ' ' par.dy];... |
---|
4842 | % 'XX 1.0';... |
---|
4843 | % ['Dt_TO ' par.Dt ' ' par.T0];... |
---|
4844 | % ['PixCmXY ' par.pxcmx ' ' par.pxcmy];... |
---|
4845 | % 'XX 1';... |
---|
4846 | % ['ShiftXY ' par.shiftx ' ' par.shifty];... |
---|
4847 | % ['Grid ' par.gridflag];... |
---|
4848 | % ['GridName ' par.gridname] ;... |
---|
4849 | % 'XX 85';... |
---|
4850 | % 'XX 1.0';... |
---|
4851 | % 'XX 1.0';... |
---|
4852 | % 'Hart 1';... |
---|
4853 | % 'DecimalShift 0';... |
---|
4854 | % 'Deformation 0';... |
---|
4855 | % 'CorrelationMin 0';... |
---|
4856 | % 'IntensityMin 0';... |
---|
4857 | % 'SeuilImage n';... |
---|
4858 | % 'SeuilImageValues 0 4096';... |
---|
4859 | % ['ImageToUse ' par.term_a ' ' par.term_b];... % VERIFIER ? |
---|
4860 | % 'ImageUsedBefore null null'}; |
---|
4861 | % |
---|
4862 | % textout=char(textcmx); |
---|
4863 | |
---|
4864 | fid=fopen([filename '.cmx'],'w'); |
---|
4865 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
4866 | fprintf(fid, ['FirstImage ' par.filename_ima_a '\n' ]); |
---|
4867 | fprintf(fid, ['LastImage ' par.filename_ima_b '\n' ]); |
---|
4868 | fprintf(fid, ['XX' '\n' ]); |
---|
4869 | fprintf(fid, ['Mask ' par.maskflag '\n' ]); |
---|
4870 | fprintf(fid, ['MaskName ' par.maskname '\n' ]); |
---|
4871 | fprintf(fid, ['ImageSize ' par.npx ' ' par.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
4872 | fprintf(fid, ['CorrelationBoxesSize ' par.ibx ' ' par.iby '\n' ]); |
---|
4873 | fprintf(fid, ['SearchBoxeSize ' par.isx ' ' par.isy '\n' ]); |
---|
4874 | fprintf(fid, ['RO ' par.rho '\n' ]); |
---|
4875 | fprintf(fid, ['GridSpacing ' par.dx ' ' par.dy '\n' ]); |
---|
4876 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4877 | fprintf(fid, ['Dt_TO ' par.Dt ' ' par.T0 '\n' ]); |
---|
4878 | fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]); |
---|
4879 | fprintf(fid, ['XX 1' '\n' ]); |
---|
4880 | fprintf(fid, ['ShiftXY ' par.shiftx ' ' par.shifty '\n' ]); |
---|
4881 | fprintf(fid, ['Grid ' par.gridflag '\n' ]); |
---|
4882 | fprintf(fid, ['GridName ' par.gridname '\n' ]); |
---|
4883 | fprintf(fid, ['XX 85' '\n' ]); |
---|
4884 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4885 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4886 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
4887 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
4888 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
4889 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
4890 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
4891 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
4892 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
4893 | fprintf(fid, ['ImageToUse ' par.term_a ' ' par.term_b '\n' ]); % VERIFIER ? |
---|
4894 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
4895 | fclose(fid); |
---|
4896 | |
---|
4897 | % if sge |
---|
4898 | cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx' ]; % redirect standard output to the log file |
---|
4899 | % else |
---|
4900 | % cmd_CIV1=[civ1Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
4901 | % end |
---|
4902 | if(isunix) |
---|
4903 | [Rootbat,Filebat,extbat]=fileparts(namelog); |
---|
4904 | ncName=fullfile(Rootbat,[ Filebat '.nc']); |
---|
4905 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log' '\n' 'chmod g+w ' ncName]; |
---|
4906 | else |
---|
4907 | cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y ' namelog ' ' regexprep(namelog,'\.log','') '.civ1.log']; |
---|
4908 | end |
---|
4909 | |
---|
4910 | %------------------------------------------------------------------------ |
---|
4911 | % --- CIV1 Unified |
---|
4912 | function xml_civ1_parameters=BATCH_CIV1_Unified(filename,namelog,par) |
---|
4913 | %------------------------------------------------------------------------ |
---|
4914 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4915 | global civ1Bin CivBin%name of the executable for civ1 calculation |
---|
4916 | |
---|
4917 | civ1.image1=par.filename_ima_a; |
---|
4918 | civ1.image2=par.filename_ima_b; |
---|
4919 | civ1.imageSize_X=par.npx; |
---|
4920 | civ1.imageSize_Y=par.npy; |
---|
4921 | civ1.outputFileName=[filename '.nc']; |
---|
4922 | civ1.correlationBoxesSize_X=par.ibx; |
---|
4923 | civ1.correlationBoxesSize_Y=par.iby; |
---|
4924 | civ1.searchBoxesSize_X=par.isx; |
---|
4925 | civ1.searchBoxesSize_Y=par.isy; |
---|
4926 | civ1.globalShift_X=par.shiftx; |
---|
4927 | civ1.globalShift_Y=par.shifty; |
---|
4928 | civ1.ro=par.rho; |
---|
4929 | civ1.hart='y'; |
---|
4930 | if isequal(par.gridflag,'y') |
---|
4931 | civ1.grid=par.gridname; |
---|
4932 | else |
---|
4933 | civ1.grid='n'; |
---|
4934 | civ1.gridSpacing_X=par.dx; |
---|
4935 | civ1.gridSpacing_Y=par.dy; |
---|
4936 | end |
---|
4937 | if isequal(par.maskflag,'y') |
---|
4938 | civ1.mask=par.maskname; |
---|
4939 | end |
---|
4940 | civ1.dt=par.Dt; |
---|
4941 | civ1.unit='pixel'; |
---|
4942 | civ1.absolut_time_T0=par.T0; |
---|
4943 | civ1.pixcmx=par.pxcmx; |
---|
4944 | civ1.pixcmy=par.pxcmy; |
---|
4945 | civ1.convectFlow='n'; |
---|
4946 | |
---|
4947 | xml_civ1_parameters=civ1; |
---|
4948 | |
---|
4949 | %------------------------------------------------------------------------ |
---|
4950 | % --- CIV2 Unified |
---|
4951 | function civ2=BATCH_CIV2_Unified(filename,namelog,par) |
---|
4952 | %------------------------------------------------------------------------ |
---|
4953 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4954 | global civ2Bin CivBin%name of the executable for civ1 calculation |
---|
4955 | |
---|
4956 | civ2.image1=par.filename_ima_a; |
---|
4957 | civ2.image2=par.filename_ima_b; |
---|
4958 | civ2.imageSize_X=par.npx; |
---|
4959 | civ2.imageSize_Y=par.npy; |
---|
4960 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
4961 | civ2.outputFileName=[filename '.nc']; |
---|
4962 | civ2.correlationBoxesSize_X=par.ibx; |
---|
4963 | civ2.correlationBoxesSize_Y=par.iby; |
---|
4964 | civ2.ro=par.rho; |
---|
4965 | %civ2.decimalShift=par.decimal; |
---|
4966 | %civ2.deformation=par.deformation; |
---|
4967 | if isequal(par.decimal,'1') |
---|
4968 | civ2.decimalShift='y'; |
---|
4969 | else |
---|
4970 | civ2.decimalShift='n'; |
---|
4971 | end |
---|
4972 | if isequal(par.deformation,'1') |
---|
4973 | civ2.deformation='y'; |
---|
4974 | else |
---|
4975 | civ2.deformation='n'; |
---|
4976 | end |
---|
4977 | if isequal(par.gridflag,'y') |
---|
4978 | civ2.grid=par.gridname; |
---|
4979 | else |
---|
4980 | civ2.grid='n'; |
---|
4981 | civ2.gridSpacing_X=par.dx; |
---|
4982 | civ2.gridSpacing_Y=par.dy; |
---|
4983 | end |
---|
4984 | civ2.gridSpacing_X='10'; |
---|
4985 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
4986 | if isequal(par.maskflag,'y') |
---|
4987 | civ2.mask=par.maskname; |
---|
4988 | else |
---|
4989 | civ2.mask='n'; |
---|
4990 | end |
---|
4991 | civ2.dt=par.Dt; |
---|
4992 | civ2.unit='pixel'; |
---|
4993 | civ2.absolut_time_T0=par.T0; |
---|
4994 | civ2.pixcmx=par.pxcmx; |
---|
4995 | civ2.pixcmy=par.pxcmy; |
---|
4996 | civ2.convectFlow='n'; |
---|
4997 | civ2.pixcmx=par.pxcmx; |
---|
4998 | civ2.pixcmy=par.pxcmy; |
---|
4999 | civ2.convectFlow='n'; |
---|
5000 | |
---|
5001 | %------------------------------------------------------------------------ |
---|
5002 | % --- CIV2 CIV2 CIV2 CIV2 |
---|
5003 | function cmd_CIV2=BATCH_CIV2(filename_cmx,namelog,par,sparam) |
---|
5004 | %------------------------------------------------------------------------ |
---|
5005 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
5006 | % global civ2Bin sge%name of the executable for civ1 calculation |
---|
5007 | if isequal(par.Dt,'0') |
---|
5008 | par.Dt='1' ;%case of 'displacement' mode |
---|
5009 | end |
---|
5010 | textcmx=['############## CMX file' '\n'... |
---|
5011 | ['FirstImage ' par.filename_ima_a] '\n'... |
---|
5012 | ['LastImage ' par.filename_ima_b] '\n'... |
---|
5013 | 'XX' '\n'... |
---|
5014 | ['Mask ' par.maskflag] '\n'... |
---|
5015 | ['MaskName ' par.maskname] '\n'... |
---|
5016 | ['ImageSize ' par.npx ' ' par.npy] '\n'... |
---|
5017 | ['CorrelationBoxesSize ' par.ibx ' ' par.iby] '\n'... |
---|
5018 | ['SearchBoxeSize ' par.ibx ' ' par.iby] '\n'... |
---|
5019 | ['RO ' par.rho] '\n'... |
---|
5020 | ['GridSpacing ' par.dx ' ' par.dy] '\n'... |
---|
5021 | 'XX 1.0' '\n'... |
---|
5022 | ['Dt_TO ' par.Dt ' ' par.T0] '\n'... |
---|
5023 | ['PixCmXY ' par.pxcmx ' ' par.pxcmy] '\n'... |
---|
5024 | 'XX 1' '\n'... |
---|
5025 | ['ShiftXY 0 0'] '\n'... |
---|
5026 | ['Grid ' par.gridflag] '\n'... |
---|
5027 | ['GridName ' par.gridname] '\n'... |
---|
5028 | 'XX 85' '\n'... |
---|
5029 | 'XX 1.0' '\n'... |
---|
5030 | 'XX 1.0' '\n'... |
---|
5031 | 'Hart 1' '\n'... |
---|
5032 | ['DecimalShift ' par.decimal] '\n'... |
---|
5033 | ['Deformation ' par.deformation] '\n'... |
---|
5034 | 'CorrelationMin 0' '\n'... |
---|
5035 | 'IntensityMin 0' '\n'... |
---|
5036 | 'SeuilImage n' '\n'... |
---|
5037 | 'SeuilImageValues 0 4096' '\n'... |
---|
5038 | ['ImageToUse ' par.term_a ' ' par.term_b] '\n'... % VERIFIER ? |
---|
5039 | ['ImageUsedBefore ' par.filename_nc1]]; |
---|
5040 | textout=char(textcmx); |
---|
5041 | fid=fopen([filename_cmx '2'],'w'); |
---|
5042 | fprintf(fid,textout); |
---|
5043 | fclose(fid) |
---|
5044 | % if sge |
---|
5045 | cmd_CIV2=[sparam.Civ2Bin ' -f ' filename_cmx ]; % redirect standard output to the log file |
---|
5046 | % else |
---|
5047 | % cmd_CIV2=[civ2Bin ' -f ' filename_cmx ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
5048 | % end |
---|
5049 | |
---|
5050 | %------------------------------------------------------------------------ |
---|
5051 | % --- Executes on button press in HELP. |
---|
5052 | function HELP_Callback(hObject, eventdata, handles) |
---|
5053 | %------------------------------------------------------------------------ |
---|
5054 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
5055 | pathelp=fileparts(path_to_uvmat); |
---|
5056 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html') |
---|
5057 | 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') |
---|
5058 | else |
---|
5059 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
5060 | web([helpfile '#civ']) |
---|
5061 | end |
---|
5062 | |
---|
5063 | %------------------------------------------------------------------------ |
---|
5064 | %--read images and convert them to the uint16 format used for PIV |
---|
5065 | function A=read_image(filename,type_ima,num,movieobject) |
---|
5066 | %------------------------------------------------------------------------ |
---|
5067 | %num is the view number needed for an avi movie |
---|
5068 | switch type_ima |
---|
5069 | case 'movie' |
---|
5070 | A=read(movieobject,num); |
---|
5071 | case 'avi' |
---|
5072 | mov=aviread(filename,num); |
---|
5073 | A=frame2im(mov(1)); |
---|
5074 | case 'multimage' |
---|
5075 | A=imread(filename,num); |
---|
5076 | case 'image' |
---|
5077 | A=imread(filename); |
---|
5078 | end |
---|
5079 | siz=size(A); |
---|
5080 | if length(siz)==3;%color images |
---|
5081 | A=sum(double(A),3); |
---|
5082 | A=uint16(A); |
---|
5083 | end |
---|
5084 | |
---|
5085 | %------------------------------------------------------------------------ |
---|
5086 | function ref_i_Callback(hObject, eventdata, handles) |
---|
5087 | %------------------------------------------------------------------------ |
---|
5088 | mode_list=get(handles.mode,'String'); |
---|
5089 | mode_value=get(handles.mode,'Value'); |
---|
5090 | mode=mode_list{mode_value}; |
---|
5091 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
5092 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
5093 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
5094 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
5095 | end |
---|
5096 | |
---|
5097 | %------------------------------------------------------------------------ |
---|
5098 | function ref_j_Callback(hObject, eventdata, handles) |
---|
5099 | %------------------------------------------------------------------------ |
---|
5100 | mode_list=get(handles.mode,'String'); |
---|
5101 | mode_value=get(handles.mode,'Value'); |
---|
5102 | mode=mode_list{mode_value}; |
---|
5103 | if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
5104 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
5105 | end |
---|
5106 | if isequal(mode,'series(Dj)') || ... |
---|
5107 | (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0) |
---|
5108 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
5109 | end |
---|
5110 | |
---|
5111 | %------------------------------------------------------------------------ |
---|
5112 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
5113 | %------------------------------------------------------------------------ |
---|
5114 | mode_list=get(handles.mode,'String'); |
---|
5115 | mode_value=get(handles.mode,'Value'); |
---|
5116 | mode=mode_list{mode_value}; |
---|
5117 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
5118 | |
---|
5119 | %------------------------------------------------------------------------ |
---|
5120 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
5121 | %------------------------------------------------------------------------ |
---|
5122 | mode_list=get(handles.mode,'String'); |
---|
5123 | mode_value=get(handles.mode,'Value'); |
---|
5124 | mode=mode_list{mode_value}; |
---|
5125 | if isequal(mode,'series(Dj)') |
---|
5126 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
5127 | end |
---|
5128 | |
---|
5129 | %------------------------------------------------------------------------ |
---|
5130 | % --- Executes on button press in compare. |
---|
5131 | function compare_Callback(hObject, eventdata, handles) |
---|
5132 | %------------------------------------------------------------------------ |
---|
5133 | test=get(handles.compare,'Value'); |
---|
5134 | if test==2 || test==3 |
---|
5135 | filebase=get(handles.RootName,'String'); |
---|
5136 | browse=get(handles.browse_root,'Userdata'); |
---|
5137 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
5138 | set(handles.browse_root,'UserData',browse); |
---|
5139 | set(handles.sub_txt,'Visible','on') |
---|
5140 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
5141 | mode_store=get(handles.mode,'String');%get the present 'mode' |
---|
5142 | set(handles.compare,'UserData',mode_store);%store the mode display |
---|
5143 | set(handles.mode,'Visible','off') |
---|
5144 | if test==2 |
---|
5145 | set(handles.mode,'Visible','off') |
---|
5146 | else |
---|
5147 | set(handles.mode,'Visible','on') |
---|
5148 | end |
---|
5149 | |
---|
5150 | % open an image file with the browser |
---|
5151 | ind_opening=1;%default |
---|
5152 | browse.incr_pair=[0 0]; %default |
---|
5153 | oldfile=get(handles.RootName,'String'); |
---|
5154 | menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ... |
---|
5155 | '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';... |
---|
5156 | '*.*', 'All Files (*.*)'}; |
---|
5157 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
5158 | fileinput=[PathName FileName];%complete file name |
---|
5159 | sizf=size(fileinput); |
---|
5160 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
5161 | [path,name,ext]=fileparts(fileinput); |
---|
5162 | [path1]=fileparts(filebase); |
---|
5163 | if ~strcmp(path1,path) |
---|
5164 | msgbox_uvmat('ERROR','The two input image series must be in the same directory') |
---|
5165 | return |
---|
5166 | end |
---|
5167 | set(handles.RootName_1,'String',name); |
---|
5168 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
5169 | browse=get(handles.browse_root,'UserData'); |
---|
5170 | browse.nom_type_ima_1=nom_type; |
---|
5171 | set(handles.browse_root,'UserData',browse) |
---|
5172 | |
---|
5173 | %check image extension |
---|
5174 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
5175 | msgbox_uvmat('ERROR','The two input image series must have the same extenion name') |
---|
5176 | return |
---|
5177 | end |
---|
5178 | |
---|
5179 | %check image size |
---|
5180 | A=imread(fileinput); |
---|
5181 | npxy=get(handles.ImaExt,'UserData'); |
---|
5182 | if ~isequal(npxy(1),size(A,1))|| ~isequal(npxy(2),size(A,2)) |
---|
5183 | msgbox_uvmat('ERROR','The two input image series must have the same size') |
---|
5184 | return |
---|
5185 | end |
---|
5186 | else |
---|
5187 | set(handles.mode,'Visible','on') |
---|
5188 | set(handles.RootName_1,'Visible','Off'); |
---|
5189 | set(handles.sub_txt,'Visible','off') |
---|
5190 | set(handles.RootName_1,'String',[]); |
---|
5191 | mode_store=get(handles.compare,'UserData'); |
---|
5192 | set(handles.mode,'String',mode_store) |
---|
5193 | set(handles.test_stereo1,'Value',0) |
---|
5194 | set(handles.test_stereo2,'Value',0) |
---|
5195 | end |
---|
5196 | mode_Callback(hObject, eventdata, handles) |
---|
5197 | |
---|
5198 | %------------------------------------------------------------------------ |
---|
5199 | % --- Executes on button press in get_ref_fix1. |
---|
5200 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
5201 | %------------------------------------------------------------------------ |
---|
5202 | filebase=get(handles.RootName,'String'); |
---|
5203 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
5204 | {'*.nc', ' (*.nc)'; |
---|
5205 | '*.nc', 'netcdf files '; ... |
---|
5206 | '*.*', 'All Files (*.*)'}, ... |
---|
5207 | 'Pick a file',filebase); |
---|
5208 | |
---|
5209 | fileinput=[PathName FileName]; |
---|
5210 | sizf=size(fileinput); |
---|
5211 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
5212 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
5213 | ref.filebase=fullfile(Path,File); |
---|
5214 | ref.num_a=stra2num(str_a); |
---|
5215 | ref.num_b=stra2num(str_b); |
---|
5216 | ref.num1=str2num(field_count); |
---|
5217 | ref.num2=str2num(str2); |
---|
5218 | browse=[];%initialisation |
---|
5219 | if ~isequal(ref.ext,'.nc') |
---|
5220 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
5221 | return |
---|
5222 | end |
---|
5223 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
5224 | set(handles.ref_fix1,'UserData',ref) |
---|
5225 | menu_field{1}='civ1'; |
---|
5226 | Data=nc2struct(fileinput,[]); |
---|
5227 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
5228 | menu_field{2}='filter1'; |
---|
5229 | end |
---|
5230 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
5231 | menu_field{3}='civ2'; |
---|
5232 | end |
---|
5233 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
5234 | menu_field{4}='filter2'; |
---|
5235 | end |
---|
5236 | set(handles.field_ref1,'String',menu_field); |
---|
5237 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
5238 | set(handles.inf_sup1,'Value',2); |
---|
5239 | set(handles.thresh_vel,'String','1');%default threshold |
---|
5240 | set(handles.ref_fix1,'Enable','on') |
---|
5241 | |
---|
5242 | %------------------------------------------------------------------------ |
---|
5243 | % --- Executes on button press in get_ref_fix2. |
---|
5244 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
5245 | %------------------------------------------------------------------------ |
---|
5246 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
5247 | filebase=get(handles.RootName,'String'); |
---|
5248 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
5249 | {'*.nc', ' (*.nc)'; |
---|
5250 | '*.nc', 'netcdf files '; ... |
---|
5251 | '*.*', 'All Files (*.*)'}, ... |
---|
5252 | 'Pick a file',filebase); |
---|
5253 | fileinput=[PathName FileName]; |
---|
5254 | sizf=size(fileinput); |
---|
5255 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
5256 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
5257 | ref.filebase=fullfile(Path,File); |
---|
5258 | ref.num_a=stra2num(str_a); |
---|
5259 | ref.num_b=stra2num(str_b); |
---|
5260 | ref.num1=str2num(field_count); |
---|
5261 | ref.num2=str2num(str2); |
---|
5262 | browse=[];%initialisation |
---|
5263 | if ~isequal(ref.ext,'.nc') |
---|
5264 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
5265 | return |
---|
5266 | end |
---|
5267 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
5268 | set(handles.ref_fix2,'UserData',ref) |
---|
5269 | menu_field{1}='civ1'; |
---|
5270 | Data=nc2struct(fileinput,[]); |
---|
5271 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
5272 | menu_field{2}='filter1'; |
---|
5273 | end |
---|
5274 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
5275 | menu_field{3}='civ2'; |
---|
5276 | end |
---|
5277 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
5278 | menu_field{4}='filter2'; |
---|
5279 | end |
---|
5280 | set(handles.field_ref2,'String',menu_field); |
---|
5281 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
5282 | set(handles.inf_sup2,'Value',2); |
---|
5283 | set(handles.thresh_vel2,'String','1');%default threshold |
---|
5284 | set(handles.ref_fix2,'Enable','on') |
---|
5285 | set(handles.ref_fix2,'Visible','on') |
---|
5286 | set(handles.field_ref2,'Visible','on') |
---|
5287 | else |
---|
5288 | set(handles.ref_fix2,'Visible','off') |
---|
5289 | set(handles.field_ref2,'Visible','off') |
---|
5290 | end |
---|
5291 | |
---|
5292 | %------------------------------------------------------------------------ |
---|
5293 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
5294 | %------------------------------------------------------------------------ |
---|
5295 | set(handles.inf_sup1,'Value',1); |
---|
5296 | set(handles.field_ref1,'Value',1) |
---|
5297 | set(handles.field_ref1,'String',{' '}) |
---|
5298 | set(handles.ref_fix1,'UserData',[]); |
---|
5299 | set(handles.ref_fix1,'String',''); |
---|
5300 | set(handles.thresh_vel1,'String','0'); |
---|
5301 | |
---|
5302 | %------------------------------------------------------------------------ |
---|
5303 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
5304 | %------------------------------------------------------------------------ |
---|
5305 | set(handles.inf_sup2,'Value',1); |
---|
5306 | set(handles.field_ref2,'Value',1) |
---|
5307 | set(handles.field_ref2,'String',{' '}) |
---|
5308 | set(handles.ref_fix2,'UserData',[]); |
---|
5309 | set(handles.ref_fix2,'String',''); |
---|
5310 | set(handles.thresh_vel2,'String','0'); |
---|
5311 | |
---|
5312 | %------------------------------------------------------------------------ |
---|
5313 | % transform letters to numbers |
---|
5314 | function numres=stra2num(str) |
---|
5315 | %------------------------------------------------------------------------ |
---|
5316 | numres=double(str)-96; |
---|
5317 | if double(str) >= 48 & double(str) <= 57 % = 1 for numbers |
---|
5318 | numres=str2num(str); |
---|
5319 | end |
---|
5320 | |
---|
5321 | %------------------------------------------------------------------------ |
---|
5322 | % --- Executes on button press in test_stereo1. |
---|
5323 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
5324 | %------------------------------------------------------------------------ |
---|
5325 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
5326 | set(handles.subdomain_patch1,'Visible','on') |
---|
5327 | set(handles.rho_patch1,'Visible','on') |
---|
5328 | else |
---|
5329 | set(handles.subdomain_patch1,'Visible','off') |
---|
5330 | set(handles.rho_patch1,'Visible','off') |
---|
5331 | end |
---|
5332 | |
---|
5333 | %------------------------------------------------------------------------ |
---|
5334 | % --- Executes on button press in test_stereo2. |
---|
5335 | function test_stereo2_Callback(hObject, eventdata, handles) |
---|
5336 | %------------------------------------------------------------------------ |
---|
5337 | if isequal(get(handles.test_stereo2,'Value'),0) |
---|
5338 | set(handles.subdomain_patch2,'Visible','on') |
---|
5339 | set(handles.rho_patch2,'Visible','on') |
---|
5340 | else |
---|
5341 | set(handles.subdomain_patch2,'Visible','off') |
---|
5342 | set(handles.rho_patch2,'Visible','off') |
---|
5343 | end |
---|
5344 | |
---|
5345 | %------------------------------------------------------------------------ |
---|
5346 | % --- Executes on button press in ImaThreshold. |
---|
5347 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
5348 | %------------------------------------------------------------------------ |
---|
5349 | if isequal(get(handles.ImaThreshold,'Value'),1) |
---|
5350 | set(handles.MinIma,'Visible','on') |
---|
5351 | set(handles.MaxIma,'Visible','on') |
---|
5352 | else |
---|
5353 | set(handles.MinIma,'Visible','off') |
---|
5354 | set(handles.MaxIma,'Visible','off') |
---|
5355 | end |
---|
5356 | |
---|
5357 | %------------------------------------------------------------------------ |
---|
5358 | % --- Executes on button press in ImaThreshold2. |
---|
5359 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
5360 | %------------------------------------------------------------------------ |
---|
5361 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
5362 | set(handles.MinIma2,'Visible','on') |
---|
5363 | set(handles.MaxIma2,'Visible','on') |
---|
5364 | else |
---|
5365 | set(handles.MinIma2,'Visible','off') |
---|
5366 | set(handles.MaxIma2,'Visible','off') |
---|
5367 | end |
---|
5368 | |
---|
5369 | |
---|
5370 | |
---|
5371 | |
---|