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