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, 2011, LEGI / CNRS-UJF-INPG, sommeria@legi.grenoble-inp.fr |
---|
9 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
10 | % This file is part of the toolbox UVMAT. |
---|
11 | % |
---|
12 | % UVMAT is free software; you can redistribute it and/or modify |
---|
13 | % it under the terms of the GNU General Public License as published by |
---|
14 | % the Free Software Foundation; either version 2 of the License, or |
---|
15 | % (at your option) any later version. |
---|
16 | % |
---|
17 | % UVMAT is distributed in the hope that it will be useful, |
---|
18 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
21 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
22 | function varargout = civ(varargin) |
---|
23 | %TODO: search range |
---|
24 | |
---|
25 | % Last Modified by GUIDE v2.5 21-Nov-2011 10:58:28 |
---|
26 | % Begin initialization code - DO NOT EDIT |
---|
27 | gui_Singleton = 1; |
---|
28 | gui_State = struct('gui_Name', mfilename, ... |
---|
29 | 'gui_Singleton', gui_Singleton, ... |
---|
30 | 'gui_OpeningFcn', @civ_OpeningFcn, ... |
---|
31 | 'gui_OutputFcn', @civ_OutputFcn, ... |
---|
32 | 'gui_LayoutFcn', [] , ... |
---|
33 | 'gui_Callback', []); |
---|
34 | if nargin && ischar(varargin{1}) |
---|
35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
36 | end |
---|
37 | |
---|
38 | if nargout |
---|
39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
40 | else |
---|
41 | gui_mainfcn(gui_State, varargin{:}); |
---|
42 | end |
---|
43 | % End initialization code - DO NOT EDIT |
---|
44 | |
---|
45 | %------------------------------------------------------------------------ |
---|
46 | % --- Executes just before civ is made visible. |
---|
47 | function civ_OpeningFcn(hObject, eventdata, handles, param) |
---|
48 | %------------------------------------------------------------------------ |
---|
49 | % This function has no output args, see OutputFcn. |
---|
50 | %filebase: root name |
---|
51 | %nom_type: nomencalture used ('png_old','_i_j'...) |
---|
52 | %list of field numbers to process |
---|
53 | %subdir: subdirectory of the opened netcdf file |
---|
54 | %ind_opening: operation number advised for beginning (1=checkciv1,2=checkfix1,3=checkpatch1,4=checkciv2,5=checkfix2,6=checkpatch2), |
---|
55 | %ind_a_opening ind_b_opening chosen pair from the opened netcdf file |
---|
56 | % Choose default command line output for civ |
---|
57 | handles.output = hObject; |
---|
58 | % Update handles structure |
---|
59 | guidata(hObject, handles); |
---|
60 | set(hObject,'WindowButtonDownFcn',{'mouse_alt_gui',handles}) % allows mouse action with right button (zoom for uicontrol display) |
---|
61 | %default initial parameters |
---|
62 | filebase=''; % root file name ('filebase'.civ) |
---|
63 | ext=[]; |
---|
64 | |
---|
65 | %% read names of the .exe file to adjust the interface according to available binaries |
---|
66 | %path_uvmat=which('uvmat');% check the path detected for source file uvmat |
---|
67 | path_civ=fileparts(which('civ')); %path to civ |
---|
68 | addpath (path_civ) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
69 | errormsg=[];%default error message |
---|
70 | xmlfile='PARAM.xml'; |
---|
71 | if exist(xmlfile,'file') |
---|
72 | try |
---|
73 | t=xmltree(xmlfile); |
---|
74 | sparam=convert(t); |
---|
75 | catch |
---|
76 | errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr}; |
---|
77 | return |
---|
78 | end |
---|
79 | else |
---|
80 | errormsg=[xmlfile ' not found: path to civx binaries undefined']; |
---|
81 | return |
---|
82 | end |
---|
83 | if ~isempty(errormsg) |
---|
84 | msgbox_uvmat('ERROR',errormsg); |
---|
85 | end |
---|
86 | |
---|
87 | test_batch=0;%default: ,no batch mode available |
---|
88 | if isfield(sparam,'BatchParam') && isfield(sparam.BatchParam,'BatchMode') |
---|
89 | test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod |
---|
90 | end |
---|
91 | if test_batch==0 |
---|
92 | set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) |
---|
93 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) |
---|
94 | end |
---|
95 | if isfield(sparam.RunParam,'CivBin') |
---|
96 | if ~exist(sparam.RunParam.CivBin,'file') |
---|
97 | sparam.RunParam.CivBin=fullfile(path_civ,sparam.RunParam.CivBin); |
---|
98 | end |
---|
99 | else |
---|
100 | sparam.RunParam.CivBin=''; |
---|
101 | end |
---|
102 | |
---|
103 | %% load the list of previously browsed files in menu Open |
---|
104 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
105 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
106 | if exist(profil_perso,'file') |
---|
107 | h=load (profil_perso); |
---|
108 | if isfield(h,'MenuFile') |
---|
109 | for ifile=1:min(length(h.MenuFile),5) |
---|
110 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
111 | end |
---|
112 | end |
---|
113 | end |
---|
114 | |
---|
115 | %default input parameters: |
---|
116 | num_i1=1; % set of field i numbers |
---|
117 | num_i2=1; % set of field i numbers |
---|
118 | num_j1=1; % set of field j numbers (fields a) |
---|
119 | num_j2=1; % second set of field j numbers (fields b) |
---|
120 | %subdir='A'; % subdir for the netcdf result files |
---|
121 | ind_opening=0; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) |
---|
122 | %load the initial parameters if the interface is started from uvmat |
---|
123 | if exist('param','var')&&isstruct(param)% the interface is opened from uvmat |
---|
124 | filebase=param.RootName; |
---|
125 | nom_type_read=param.NomType; |
---|
126 | num_i1=param.num1; |
---|
127 | if isnan(num_i1),num_i1=1;end |
---|
128 | num_i2=param.num2; |
---|
129 | if isnan(num_i2),num_i2=num_i1;end |
---|
130 | num_j1=param.num_a; |
---|
131 | if isnan(num_j1),num_j1=1;end |
---|
132 | num_j2=param.num_b; |
---|
133 | if isnan(num_j2),num_j2=num_j1;end |
---|
134 | subdir=param.SubDir; |
---|
135 | ind_opening=param.IndOpening; |
---|
136 | ext=param.ImaExt; |
---|
137 | end |
---|
138 | browse.num_i1=num_i1; |
---|
139 | browse.num_i2=num_i2; |
---|
140 | browse.num_j1=num_j1; |
---|
141 | browse.num_j2=num_j2; |
---|
142 | if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
143 | set(handles.ImaExt,'String',ext) |
---|
144 | browse.ext_ima=ext; |
---|
145 | if exist('nom_type_read','var') |
---|
146 | browse.nom_type_ima=nom_type_read; % the image nomenclature is stored |
---|
147 | end |
---|
148 | elseif isequal(ext,'.nc') |
---|
149 | if exist('nom_type_read','var') |
---|
150 | browse.nom_type_nc=nom_type_read;% the netcdf nomenclature is stored |
---|
151 | end |
---|
152 | end |
---|
153 | set(handles.RootName,'String',filebase); |
---|
154 | set(handles.ImaDoc,'String',ext) |
---|
155 | |
---|
156 | %initiate advised operations |
---|
157 | enable_civ1(handles,0) |
---|
158 | enable_civ2(handles,0) |
---|
159 | %enable_pair1(handles,'on') |
---|
160 | enable_fix1(handles,0) |
---|
161 | enable_patch1(handles,0) |
---|
162 | enable_fix2(handles,0) |
---|
163 | enable_patch2(handles,0) |
---|
164 | set(handles.CheckCiv1,'Value',0) |
---|
165 | set(handles.CheckFix1,'Value',0) |
---|
166 | set(handles.CheckPatch1,'Value',0) |
---|
167 | set(handles.CheckCiv2,'Value',0) |
---|
168 | set(handles.CheckFix2,'Value',0) |
---|
169 | set(handles.CheckPatch2,'Value',0) |
---|
170 | %set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
171 | if isequal(ind_opening,1) |
---|
172 | set(handles.CheckCiv1,'Value',1) |
---|
173 | enable_civ1(handles,1) |
---|
174 | elseif isequal(ind_opening,2) |
---|
175 | set(handles.CheckFix1,'Value',1) |
---|
176 | enable_fix1(handles,1) |
---|
177 | elseif isequal(ind_opening,3) |
---|
178 | set(handles.CheckPatch1,'Value',1) |
---|
179 | enable_patch1(handles,1) |
---|
180 | elseif isequal(ind_opening,4) |
---|
181 | set(handles.CheckCiv2,'Value',1) |
---|
182 | enable_civ2(handles,1) |
---|
183 | elseif isequal(ind_opening,5) |
---|
184 | set(handles.CheckFix2,'Value',1) |
---|
185 | enable_fix2(handles,1) |
---|
186 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
187 | set(handles.ListPairCiv2,'Enable','On') |
---|
188 | set(handles.ListPairCiv2,'Enable','On') |
---|
189 | enable_pair1(handles,'off') |
---|
190 | elseif isequal(ind_opening,6) |
---|
191 | set(handles.CheckPatch2,'Value',1) |
---|
192 | enable_patch2(handles,1) |
---|
193 | % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
194 | set(handles.ListPairCiv2,'Enable','On') |
---|
195 | enable_pair1(handles,'off') |
---|
196 | end |
---|
197 | |
---|
198 | % set the range of fields (1:1 by default) and selected pair |
---|
199 | if isequal(num_i2,num_i1) |
---|
200 | num_ref_i=num_i1; |
---|
201 | else |
---|
202 | num_ref_i=floor((num_i1+num_i2)/2); |
---|
203 | browse.incr_pair(1)=num_i2-num_i1; |
---|
204 | browse.incr_pair(2)=0; |
---|
205 | end |
---|
206 | if isequal(num_j1,num_j2) |
---|
207 | if isnan(num_j1) |
---|
208 | num_ref_j=1; |
---|
209 | else |
---|
210 | num_ref_j=num_j1; |
---|
211 | end |
---|
212 | else |
---|
213 | num_ref_j=floor((num_j1+num_j2)/2); |
---|
214 | browse.incr_pair(2)=num_j2-num_j1; |
---|
215 | end |
---|
216 | set(handles.first_i,'String',num2str(num_ref_i)); |
---|
217 | set(handles.last_i,'String',num2str(num_ref_i)); |
---|
218 | set(handles.first_j,'String',num2str(num_ref_j)); |
---|
219 | set(handles.last_j,'String',num2str(num_ref_j)); |
---|
220 | set(handles.ref_i,'String',num2str(num_ref_i)); |
---|
221 | set(handles.ref_j,'String',num2str(num_ref_j)); |
---|
222 | % set(handles.ref_i_civ2,'String',num2str(num_ref_i)); |
---|
223 | % set(handles.ref_j_civ2,'String',num2str(num_ref_j)); |
---|
224 | set(handles.RootName,'UserData',browse); |
---|
225 | if exist('param','var') && isfield(param,'RootName') && ~isempty(param.RootName)%varargin the interface is opened from uvmat |
---|
226 | RootName_Callback(hObject, eventdata, handles); |
---|
227 | end |
---|
228 | |
---|
229 | %------------------------------------------------------------------------ |
---|
230 | % --- Outputs from this function are returned to the command line. |
---|
231 | function varargout = civ_OutputFcn(hObject, eventdata, handles) |
---|
232 | %------------------------------------------------------------------------ |
---|
233 | % varargout cell array for returning output args (see VARARGOUT); |
---|
234 | % hObject handle to figure |
---|
235 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
236 | % handles structure with handles and user data (see GUIDATA) |
---|
237 | % Get default command line output from handles structure |
---|
238 | varargout{1} = handles.output; |
---|
239 | |
---|
240 | % -------------------------------------------------------------------- |
---|
241 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
242 | |
---|
243 | %get the input file properties |
---|
244 | filebase=get(handles.RootName,'String'); |
---|
245 | oldfile=''; %default |
---|
246 | if isempty(filebase)|| isequal(filebase,'')%loads the previously stored file name and set it as default in the file_input box |
---|
247 | dir_perso=prefdir; |
---|
248 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
249 | if exist(profil_perso,'file') |
---|
250 | h=load (profil_perso); |
---|
251 | if isfield(h,'filebase')&& ischar(h.filebase) |
---|
252 | oldfile=h.filebase; |
---|
253 | end |
---|
254 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
255 | oldfile=h.RootPath; |
---|
256 | end |
---|
257 | end |
---|
258 | else |
---|
259 | oldfile=filebase; |
---|
260 | end |
---|
261 | ind_opening=1;%default |
---|
262 | browse.incr_pair=[0 0]; %default |
---|
263 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
264 | '*.xml', '.xml files '; ... |
---|
265 | '*.civ', '.civ files '; ... |
---|
266 | '*.png','.png image files'; ... |
---|
267 | '*.jpg',' jpeg image files'; ... |
---|
268 | '*.tif','.tif image files'; ... |
---|
269 | '*.avi;*.AVI','.avi movie files'; ... |
---|
270 | '*.nc','.netcdf files'; ... |
---|
271 | '*.*', 'All Files (*.*)'}; |
---|
272 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); |
---|
273 | fileinput=[PathName FileName];%complete file name |
---|
274 | sizf=size(fileinput); |
---|
275 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
276 | [path,name,ext]=fileparts(fileinput); |
---|
277 | testeditxml=0; |
---|
278 | if isequal(ext,'.xml') |
---|
279 | testeditxml=1; |
---|
280 | t_browse=xmltree(fileinput); |
---|
281 | head_element=get(t_browse,1); |
---|
282 | if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc') |
---|
283 | testeditxml=0; |
---|
284 | end |
---|
285 | end |
---|
286 | if testeditxml==1 || isequal(ext,'.xls') |
---|
287 | heditxml=editxml({fileinput}); |
---|
288 | set(heditxml,'Tag','browser') |
---|
289 | waitfor(heditxml,'Tag','idle') |
---|
290 | if ~ishandle(heditxml) |
---|
291 | return |
---|
292 | end |
---|
293 | attr=findobj(get(heditxml,'children'),'Tag','CurrentAttributes'); |
---|
294 | set(handles.browse,'UserData',fileinput)% store for future opening with browser |
---|
295 | fileinput=get(attr,'UserData'); |
---|
296 | if ~exist(fileinput,'file') |
---|
297 | return |
---|
298 | end |
---|
299 | end |
---|
300 | [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); |
---|
301 | filebase=fullfile(RootPath,RootFile); |
---|
302 | num_i1=str2double(str1); |
---|
303 | if isnan(num_i1),num_i1=1;end |
---|
304 | num_i2=str2double(str2); |
---|
305 | if isnan(num_i2),num_i2=num_i1;end |
---|
306 | num_j1=stra2num(str_a); |
---|
307 | if isnan(num_j1),num_j1=1;end |
---|
308 | num_j2=stra2num(str_b); |
---|
309 | if isnan(num_j2),num_j2=num_j1;end |
---|
310 | if isequal(get(handles.ListCompareMode,'Value'),1) |
---|
311 | browse=[];%initialisation |
---|
312 | else |
---|
313 | browse=get(handlesRootName,'UserData'); |
---|
314 | end |
---|
315 | browse.num_i1=num_i1; |
---|
316 | browse.num_i2=num_i2; |
---|
317 | browse.num_j1=num_j1; |
---|
318 | browse.num_j2=num_j2; |
---|
319 | if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat |
---|
320 | browse.nom_type_ima=nom_type; |
---|
321 | browse.ext_ima=ext; |
---|
322 | set(handles.ImaExt,'String',ext) |
---|
323 | end |
---|
324 | set(handles.ImaDoc,'String',ext); |
---|
325 | |
---|
326 | %%%%% read the state of the selected netcdf file to advise default operation |
---|
327 | if isequal(ext,'.nc') |
---|
328 | browse.nom_type_nc=nom_type; |
---|
329 | ind_opening=2;% propose 'fix' as the default option |
---|
330 | Data=nc2struct(fileinput,'ListGlobalAttribute','CivStage','absolut_time_T0','fix','patch','civ2','fix2'); |
---|
331 | if ~isempty(Data.CivStage)%test for civ files |
---|
332 | ind_opening=Data.CivStage; |
---|
333 | set(handles.ListPairMode,'Value',3) |
---|
334 | end |
---|
335 | if ~isempty(Data.absolut_time_T0)%test for civx files |
---|
336 | set(handles.ListPairMode,'Value',1) |
---|
337 | if isfield(Data,'fix') && isequal(Data.fix,1) |
---|
338 | ind_opening=3; |
---|
339 | end |
---|
340 | if isequal(Data.patch,1) |
---|
341 | ind_opening=4; |
---|
342 | end |
---|
343 | if isequal(Data.civ2,1) |
---|
344 | ind_opening=5; |
---|
345 | end |
---|
346 | if isequal(Data.fix2,1) |
---|
347 | ind_opening=6; |
---|
348 | end |
---|
349 | testciv=1; %TO SUPPRESS WITH NEW VERSION OF CIVX |
---|
350 | else |
---|
351 | ind_opening=3; %GUI used only for patch |
---|
352 | testciv=0; |
---|
353 | end |
---|
354 | set(handles.txt_SubdirCiv1,'String',subdir);%set the default subdir directories for installing the .nc results |
---|
355 | set(handles.txt_SubdirCiv2,'String',subdir); |
---|
356 | browse.testciv=testciv; |
---|
357 | browse.ind_opening=ind_opening; |
---|
358 | end |
---|
359 | set(handles.RootName,'String',filebase); |
---|
360 | set(handles.ImaDoc,'String',ext); |
---|
361 | if ~isempty(num_i1) |
---|
362 | ref_i=num_i1; |
---|
363 | if ~isempty(num_i2) |
---|
364 | ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file |
---|
365 | browse.incr_pair(1)=num_i2-num_i1; |
---|
366 | browse.incr_pair(2)=0; |
---|
367 | end |
---|
368 | set(handles.first_i,'String',num2str(ref_i)); |
---|
369 | set(handles.last_i,'String',num2str(ref_i)); |
---|
370 | set(handles.ref_i,'String',num2str(ref_i)); |
---|
371 | % set(handles.ref_i_civ2,'String',num2str(ref_i)) |
---|
372 | end |
---|
373 | if isempty(num_j1) |
---|
374 | set(handles.ref_j,'String','1'); |
---|
375 | set(handles.ref_j_civ2,'String','1'); |
---|
376 | else |
---|
377 | ref_j=num_j1; |
---|
378 | if ~isempty(num_j2) |
---|
379 | ref_j=floor((num_j1+num_j2)/2); |
---|
380 | browse.incr_pair(2)=num_j2-num_j1; |
---|
381 | end |
---|
382 | set(handles.first_j,'String',num2str(ref_j)); |
---|
383 | set(handles.last_j,'String',num2str(ref_j)); |
---|
384 | set(handles.ref_j,'String',num2str(ref_j)); |
---|
385 | % set(handles.ref_j_civ2,'String',num2str(ref_j)); |
---|
386 | end |
---|
387 | |
---|
388 | % set default operation options |
---|
389 | enable_civ1(handles,0) |
---|
390 | enable_civ2(handles,0') |
---|
391 | enable_pair1(handles,'on') |
---|
392 | enable_fix1(handles,0) |
---|
393 | enable_patch1(handles,0) |
---|
394 | enable_fix2(handles,0) |
---|
395 | enable_patch2(handles,0) |
---|
396 | set(handles.CheckCiv1,'Value',0) |
---|
397 | set(handles.CheckFix1,'Value',0) |
---|
398 | set(handles.CheckPatch1,'Value',0) |
---|
399 | set(handles.CheckCiv2,'Value',0) |
---|
400 | set(handles.CheckFix2,'Value',0) |
---|
401 | set(handles.CheckPatch2,'Value',0) |
---|
402 | % set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
403 | if isequal(ind_opening,1) |
---|
404 | set(handles.CheckCiv1,'Value',1) |
---|
405 | enable_civ1(handles,'on') |
---|
406 | elseif isequal(ind_opening,2) |
---|
407 | set(handles.CheckFix1,'Value',1) |
---|
408 | enable_fix1(handles,'on') |
---|
409 | elseif isequal(ind_opening,3) |
---|
410 | set(handles.CheckPatch1,'Value',1) |
---|
411 | enable_patch1(handles) |
---|
412 | elseif isequal(ind_opening,4) |
---|
413 | set(handles.CheckCiv2,'Value',1) |
---|
414 | enable_civ2(handles,'on') |
---|
415 | elseif isequal(ind_opening,5) |
---|
416 | enable_pair1(handles,'off') |
---|
417 | set(handles.CheckFix2,'Value',1) |
---|
418 | enable_fix2(handles) |
---|
419 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
420 | set(handles.ListPairCiv2,'Enable','On') |
---|
421 | set(handles.ListPairCiv2,'Enable','On') |
---|
422 | elseif isequal(ind_opening,6) |
---|
423 | enable_pair1(handles,'off') |
---|
424 | set(handles.CheckPatch2,'Value',1) |
---|
425 | enable_patch2(handles) |
---|
426 | set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
427 | set(handles.ListPairCiv2,'Enable','On') |
---|
428 | end |
---|
429 | set(handles.RootName,'UserData',browse);% store information from browser |
---|
430 | RootName_Callback(hObject, eventdata, handles); |
---|
431 | |
---|
432 | |
---|
433 | % ----------------------------------------------------------------------- |
---|
434 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
435 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
436 | %------------------------------------------------------------------------ |
---|
437 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
438 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
439 | |
---|
440 | % ----------------------------------------------------------------------- |
---|
441 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
442 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
443 | %------------------------------------------------------------------------ |
---|
444 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
445 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
446 | |
---|
447 | % ----------------------------------------------------------------------- |
---|
448 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
449 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
450 | %------------------------------------------------------------------------ |
---|
451 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
452 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
453 | |
---|
454 | % ----------------------------------------------------------------------- |
---|
455 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
456 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
457 | %------------------------------------------------------------------------ |
---|
458 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
459 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
460 | |
---|
461 | % ----------------------------------------------------------------------- |
---|
462 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
463 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
464 | %------------------------------------------------------------------------ |
---|
465 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
466 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
467 | |
---|
468 | %------------------------------------------------------------------------ |
---|
469 | function ImaDoc_Callback(hObject, eventdata, handles) |
---|
470 | %------------------------------------------------------------------------ |
---|
471 | RootName_Callback(hObject, eventdata, handles) |
---|
472 | |
---|
473 | %------------------------------------------------------------------------ |
---|
474 | % --- function activated when a new filebase (image series) is introduced |
---|
475 | function RootName_Callback(hObject, eventdata, handles) |
---|
476 | %------------------------------------------------------------------------ |
---|
477 | filebase=get(handles.RootName,'String'); |
---|
478 | display_file_name(hObject, eventdata, handles,filebase) |
---|
479 | |
---|
480 | %------------------------------------------------------------------------ |
---|
481 | function display_file_name(hObject, eventdata, handles,filebase) |
---|
482 | %------------------------------------------------------------------------ |
---|
483 | set(handles.ListCompareMode,'Visible','on') |
---|
484 | ext_ima='';%default |
---|
485 | nom_type_ima=[];%default |
---|
486 | field_count=1;%default |
---|
487 | nom_type_nc=[]; |
---|
488 | time=[]; |
---|
489 | TimeUnit='frame'; %default |
---|
490 | CoordUnit='px';%default |
---|
491 | pxcmx_search=[];%default |
---|
492 | pxcmy_search=[];%default |
---|
493 | |
---|
494 | ext_imadoc=get(handles.ImaDoc,'String'); |
---|
495 | browse=get(handles.RootName,'UserData');%default |
---|
496 | if isfield(browse,'nom_type_ima') |
---|
497 | nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name |
---|
498 | end |
---|
499 | if isfield(browse,'ext_ima') |
---|
500 | ext_ima=browse.ext_ima; |
---|
501 | end |
---|
502 | if isfield(browse,'nom_type_nc') |
---|
503 | nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name |
---|
504 | end |
---|
505 | if isfield(browse,'num_i1') |
---|
506 | field_count=browse.num_i1;% get an image index type already determined by an input file |
---|
507 | end |
---|
508 | set(handles.civ,'UserData',[]); %refresh list of previous civ files (for STATUS) |
---|
509 | |
---|
510 | %default first_i and j and increments |
---|
511 | first_i=str2double(get(handles.first_i,'String'));%value possibly set by uvmat_Opening |
---|
512 | if isnan(first_i)|| first_i < 1 |
---|
513 | first_i=1; %default first_i |
---|
514 | end |
---|
515 | last_i=str2double(get(handles.last_i,'String')); |
---|
516 | if isnan(last_i)|| last_i < first_i |
---|
517 | last_i=first_i; %default last_i |
---|
518 | end |
---|
519 | first_j=str2double(get(handles.first_j,'String')); |
---|
520 | if isnan(first_j)|| first_j < 1 |
---|
521 | first_j=1; %default first_j |
---|
522 | end |
---|
523 | last_j=str2double(get(handles.last_j,'String')); |
---|
524 | if isnan(last_j)|| last_j < first_j |
---|
525 | last_j=first_j; %default last_j |
---|
526 | end |
---|
527 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
528 | if isnan(incr_i) || incr_i < 1; |
---|
529 | set(handles.incr_i,'String','1') %default incr_i |
---|
530 | end |
---|
531 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
532 | if isnan(incr_j) || incr_j < 1; |
---|
533 | set(handles.incr_j,'String','1') %default incr_j |
---|
534 | end |
---|
535 | dt=[];%default |
---|
536 | testmode=0;%default |
---|
537 | nbfield=[]; %default |
---|
538 | nburst=[];%default |
---|
539 | pxcmx=1; |
---|
540 | pxcmy=1; |
---|
541 | |
---|
542 | %look for an image documentation file |
---|
543 | if ~strcmp(ext_imadoc,'.xml') && ~strcmp(ext_imadoc,'.civ')&& ~strcmpi(ext_imadoc,'.avi') |
---|
544 | if exist([filebase '.xml'],'file') |
---|
545 | ext_imadoc='.xml'; |
---|
546 | elseif exist([filebase '.civxml'],'file') |
---|
547 | ext_imadoc='.civxml'; |
---|
548 | elseif exist([filebase '.civ'],'file') |
---|
549 | ext_imadoc='.civ'; |
---|
550 | elseif exist([filebase '.avi'],'file') |
---|
551 | ext_imadoc='.avi'; |
---|
552 | elseif exist([filebase '.AVI'],'file') |
---|
553 | ext_imadoc='.AVI'; |
---|
554 | end |
---|
555 | set(handles.ImaDoc,'String',ext_imadoc) |
---|
556 | end |
---|
557 | |
---|
558 | %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
559 | mode=''; %default |
---|
560 | set(handles.ImaDoc,'BackgroundColor',[1 1 0]) |
---|
561 | drawnow |
---|
562 | if isequal(ext_imadoc,'.civxml') || isequal(ext_imadoc,'.xml')|| isequal(ext_imadoc,'.civ') |
---|
563 | set(handles.ref_i,'Visible','On')%use a reference index |
---|
564 | set(handles.ref_j,'Visible','On') |
---|
565 | elseif isequal(ext_imadoc,'.avi') || isequal(ext_imadoc,'.AVI') |
---|
566 | set(handles.ref_j,'Visible','Off') |
---|
567 | else |
---|
568 | set(handles.ref_i,'Visible','Off') |
---|
569 | set(handles.ref_j,'Visible','Off') |
---|
570 | end |
---|
571 | testima_xml=0; |
---|
572 | if isequal(ext_imadoc,'.civxml')%TO ABANDON |
---|
573 | [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']); |
---|
574 | mode='pair j1-j2'; |
---|
575 | if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat |
---|
576 | nom_type_ima='_i_j'; |
---|
577 | end |
---|
578 | elseif isequal(ext_imadoc,'.xml') |
---|
579 | [XmlData,warntext]=imadoc2struct([filebase '.xml']); |
---|
580 | ext_ima_read=[]; |
---|
581 | nom_type_read=[]; |
---|
582 | if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file |
---|
583 | [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName); |
---|
584 | fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file, |
---|
585 | if ~exist(fullname,'file') |
---|
586 | msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) |
---|
587 | end |
---|
588 | end |
---|
589 | if isfield(XmlData,'Time') |
---|
590 | time=XmlData.Time; |
---|
591 | nbfield=size(time,1); |
---|
592 | nbfield2=size(time,2); |
---|
593 | %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml |
---|
594 | if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector |
---|
595 | if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D')) |
---|
596 | time=time'; |
---|
597 | nbfield=nbfield2; |
---|
598 | nbfield2=1; |
---|
599 | end |
---|
600 | end |
---|
601 | end |
---|
602 | if isfield(XmlData,'TimeUnit') |
---|
603 | TimeUnit=XmlData.TimeUnit; |
---|
604 | end |
---|
605 | if isfield(XmlData,'Npx') |
---|
606 | npx=XmlData.Npx; |
---|
607 | npy=XmlData.Npy; |
---|
608 | end |
---|
609 | pxcmx_search=1; |
---|
610 | pxcmy_search=1; |
---|
611 | if isfield(XmlData,'GeometryCalib') |
---|
612 | tsai=XmlData.GeometryCalib; |
---|
613 | if isfield(tsai,'f') && isfield(tsai,'Tz') && isfield(tsai,'dpx') && isfield(tsai,'dpy')&& isfield(tsai,'R') |
---|
614 | rot2D=tsai.R(1:2,[1,2]); |
---|
615 | pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); |
---|
616 | pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); |
---|
617 | end |
---|
618 | if isfield(tsai,'CoordUnit') |
---|
619 | CoordUnit=tsai.CoordUnit; |
---|
620 | end |
---|
621 | end |
---|
622 | elseif strcmp(ext_imadoc,'.civ')% case of .civ image documentation file |
---|
623 | [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']); |
---|
624 | if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']); |
---|
625 | elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
626 | end |
---|
627 | nom_type_ima='001a'; |
---|
628 | elseif strcmpi(ext_imadoc,'.avi') |
---|
629 | nom_type_ima='*'; |
---|
630 | ext_ima=ext_imadoc; |
---|
631 | set(handles.ListPairMode,'Value',1); |
---|
632 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
633 | dt=0.04;%default |
---|
634 | if exist([filebase ext_imadoc],'file')==2 |
---|
635 | info=aviinfo([filebase ext_imadoc]);%read infos on the avi movie |
---|
636 | dt=1/info.FramesPerSecond;%time interval between successive frames |
---|
637 | nbfield=info.NumFrames;%number of frames |
---|
638 | end |
---|
639 | time=(dt*(0:nbfield-1))';%list of image times |
---|
640 | end |
---|
641 | if isempty(time) |
---|
642 | set(handles.ImaDoc,'String',''); %xml file not used for timing |
---|
643 | end |
---|
644 | set(handles.ImaDoc,'BackgroundColor',[1 1 1]) |
---|
645 | |
---|
646 | %get the imabe nomenclature type if not defined by the input file nor by the xml file |
---|
647 | dirima=[];%default |
---|
648 | if isempty(nom_type_ima) |
---|
649 | %look for double image series '_i_j' |
---|
650 | dirima=dir([filebase '_' num2str(first_i) '_' num2str(first_j) '.*']); |
---|
651 | if isempty(dirima) |
---|
652 | % look for images series with sub marker '_' |
---|
653 | dirima=dir([filebase '_*' num2str(first_i) '.*']); |
---|
654 | if isempty(dirima) |
---|
655 | % look for other images series |
---|
656 | dirima=dir([filebase '*' num2str(first_i) '.*']); |
---|
657 | if isempty(dirima) |
---|
658 | % look for other images series witth letter appendix |
---|
659 | appendix=char(96+first_j); |
---|
660 | dirima=dir([filebase '*' num2str(first_i) appendix '.*']); |
---|
661 | end |
---|
662 | end |
---|
663 | end |
---|
664 | end |
---|
665 | for ilist=1:numel(dirima) |
---|
666 | [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name); |
---|
667 | form=imformats(ext_list(2:end)); |
---|
668 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
669 | ext_ima=ext_list; |
---|
670 | nom_type_ima=nom_type_list; |
---|
671 | break |
---|
672 | end |
---|
673 | end |
---|
674 | % no image documentation file found: look for a series of existing files,images by priority or .nc files |
---|
675 | if isempty(nom_type_ima) |
---|
676 | ext_search=ext_imadoc; |
---|
677 | nom_type_search=nom_type_nc; |
---|
678 | else |
---|
679 | ext_search=ext_ima; |
---|
680 | nom_type_search=nom_type_ima; |
---|
681 | end |
---|
682 | if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*') |
---|
683 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
684 | incr_pair=[0 0];%default |
---|
685 | if isfield(browse,'incr_pair') |
---|
686 | incr_pair=browse.incr_pair; |
---|
687 | end |
---|
688 | % nbdetect=0;%test of detected images |
---|
689 | field_i=browse.num_i2; |
---|
690 | imagename=name_generator(filebase,field_i,1,ext_search,nom_type_search); |
---|
691 | imagename_plus=''; |
---|
692 | idetect=1; |
---|
693 | while idetect %look for the maximum file number in the series |
---|
694 | imagename_plus=name_generator(filebase,field_i+1,1,ext_search,nom_type_search); |
---|
695 | idetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
696 | if idetect |
---|
697 | field_i=field_i+1; |
---|
698 | end |
---|
699 | %SEE CASE OF NETCDF FILES |
---|
700 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
701 | end |
---|
702 | nbfield=field_i;% last detected field number |
---|
703 | field_i=browse.num_i1;%look for the minimum file number in the series |
---|
704 | imagename_min=''; |
---|
705 | idetect=1; |
---|
706 | while idetect==1 |
---|
707 | imagename_min=name_generator(filebase,field_i-1,1,ext_search,nom_type_search); |
---|
708 | idetect=(exist(imagename_min,'file')==2)&& ~strcmp(imagename,imagename_min); |
---|
709 | if idetect |
---|
710 | field_i=field_i-1; |
---|
711 | end |
---|
712 | end |
---|
713 | first_i=max(field_i,1); |
---|
714 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
715 | field_i=browse.num_i1; |
---|
716 | field_j=browse.num_j2; |
---|
717 | imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search); |
---|
718 | imagename_plus=''; |
---|
719 | jdetect=1; |
---|
720 | while jdetect==1 %look for the maximum file number in the series |
---|
721 | imagename_plus=name_generator(filebase,field_i,field_j+1,ext_search,nom_type_search); |
---|
722 | jdetect=(exist(imagename_plus,'file')==2)&& ~strcmp(imagename,imagename_plus); |
---|
723 | if jdetect |
---|
724 | field_j=field_j+1; |
---|
725 | end |
---|
726 | %SEE CASE OF NETCDF FILES |
---|
727 | % nbdetect=nbdetect+(exist(imagename,'file')==2); |
---|
728 | end |
---|
729 | nbfield2=field_j;% last detected field number |
---|
730 | end |
---|
731 | |
---|
732 | %determine the set of times and possible intervals for CIV |
---|
733 | % dt=(1/1000)*str2double(get(handles.dt,'String')); |
---|
734 | time=(0:nbfield-1)';% time=file index -1 by default |
---|
735 | if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j |
---|
736 | [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1); |
---|
737 | time=x+y; |
---|
738 | end |
---|
739 | end |
---|
740 | |
---|
741 | if exist('time','var') |
---|
742 | if size(time,1)+size(time,2)>=3 % if there are at least two time values to define dt |
---|
743 | nbfield=size(time,1); |
---|
744 | nbfield2=size(time,2); |
---|
745 | set(handles.ImaDoc,'UserData',time); %store the set of times |
---|
746 | set(handles.dt_unit,'String',['dt in m' TimeUnit]); |
---|
747 | % set(handles.dt_unit_civ2,'String',['dt in m' TimeUnit]); |
---|
748 | set(handles.TimeUnit,'String',TimeUnit); |
---|
749 | set(handles.nb_field,'String',num2str(nbfield)); |
---|
750 | set(handles.nb_field2,'String',num2str(nbfield2)); |
---|
751 | end |
---|
752 | end |
---|
753 | set(handles.CoordUnit,'String',CoordUnit) |
---|
754 | set(handles.SearchRange,'UserData',[pxcmx_search pxcmy_search]); |
---|
755 | % npxy=[npy npx]; |
---|
756 | set(handles.ImaExt,'String',ext_ima) |
---|
757 | set(handles.first_i,'String',num2str(first_i)); |
---|
758 | set(handles.last_i,'String',num2str(last_i));% |
---|
759 | set(handles.first_j,'String',num2str(first_j)); |
---|
760 | set(handles.last_j,'String',num2str(last_j));% |
---|
761 | browse.nom_type_ima=nom_type_ima; |
---|
762 | set(handles.RootName,'UserData',browse)% store the nomenclature type |
---|
763 | |
---|
764 | %% set the menus of image pairs and default selection for civ %%%%%%%%%%%%%%%%%%% |
---|
765 | test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'));%images with single indexing |
---|
766 | if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1)) |
---|
767 | set(handles.ListPairMode,'Value',1) |
---|
768 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
769 | elseif (nbfield==1)% simple series in j |
---|
770 | set(handles.ListPairMode,'Value',1) |
---|
771 | set(handles.ListPairMode,'String',{'series(Dj)'}) |
---|
772 | else |
---|
773 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
774 | if nbfield2 <= 10 |
---|
775 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' for small burst |
---|
776 | end |
---|
777 | end |
---|
778 | |
---|
779 | |
---|
780 | %% desable status and RUN button |
---|
781 | set(handles.RUN, 'Enable','On') |
---|
782 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
783 | set(handles.BATCH,'Enable','On') |
---|
784 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
785 | if isfield(handles,'status') |
---|
786 | set(handles.status,'Value',0);%suppress status display |
---|
787 | status_Callback(hObject, eventdata, handles) |
---|
788 | end |
---|
789 | |
---|
790 | %% store the root input filename for future opening |
---|
791 | dir_perso=prefdir; |
---|
792 | profil_perso=fullfile(prefdir,'uvmat_perso.mat'); |
---|
793 | RootPath=fileparts(filebase); |
---|
794 | if exist(profil_perso,'file') |
---|
795 | save (profil_perso,'RootPath','-append'); %store the root name for future opening of uvmat |
---|
796 | else |
---|
797 | txt=ver('MATLAB'); |
---|
798 | Release=txt.Release; |
---|
799 | relnumb=str2double(Release(3:4)); |
---|
800 | if relnumb >= 14 |
---|
801 | save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat |
---|
802 | else |
---|
803 | save (profil_perso,'RootPath'); %store the root name for future opening of uvmat |
---|
804 | end |
---|
805 | end |
---|
806 | |
---|
807 | %% update the subdir |
---|
808 | pathdir=fileparts(filebase);%path to the current xml file |
---|
809 | listot=dir(pathdir); |
---|
810 | idir=0; |
---|
811 | listdir={''};%default |
---|
812 | for ilist=1:length(listot) |
---|
813 | if listot(ilist).isdir |
---|
814 | name=listot(ilist).name; |
---|
815 | if ~isequal(name,'.') && ~isequal(name,'..') |
---|
816 | idir=idir+1; |
---|
817 | listdir{idir,1}=listot(ilist).name; |
---|
818 | end |
---|
819 | end |
---|
820 | end |
---|
821 | set(handles.ListSubdirCiv1,'Value',1) |
---|
822 | set(handles.ListSubdirCiv2,'Value',1) |
---|
823 | set(handles.ListSubdirCiv1,'String',[listdir;'new...']) |
---|
824 | set(handles.ListSubdirCiv2,'String',[listdir;'new...']) |
---|
825 | if isempty(listdir) |
---|
826 | dirname=listdir{1}; |
---|
827 | else |
---|
828 | dirname='CIV'; %default civ directory name |
---|
829 | end |
---|
830 | set(handles.txt_SubdirCiv1,'String',dirname) |
---|
831 | set(handles.txt_SubdirCiv2,'String',dirname) |
---|
832 | %check wether the current subdir exists: |
---|
833 | % txt_SubdirCiv1=get(handles.txt_SubdirCiv1,'String'); |
---|
834 | % txt_SubdirCiv2=get(handles.txt_SubdirCiv2,'String'); |
---|
835 | |
---|
836 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
837 | |
---|
838 | %------------------------------------------------------------------------ |
---|
839 | % --- Executes on button press in ListPairMode. |
---|
840 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
841 | %------------------------------------------------------------------------ |
---|
842 | browse=get(handles.RootName,'UserData'); |
---|
843 | compare_list=get(handles.ListCompareMode,'String'); |
---|
844 | val=get(handles.ListCompareMode,'Value'); |
---|
845 | compare=compare_list{val}; |
---|
846 | if strcmp(compare,'displacement') |
---|
847 | mode='displacement'; |
---|
848 | else |
---|
849 | mode_list=get(handles.ListPairMode,'String'); |
---|
850 | if ischar(mode_list) |
---|
851 | mode_list={mode_list}; |
---|
852 | end |
---|
853 | mode_value=get(handles.ListPairMode,'Value'); |
---|
854 | mode=mode_list{mode_value}; |
---|
855 | end |
---|
856 | displ_num=[];%default |
---|
857 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
858 | % last_i=str2num(get(handles.last_i,'String')); |
---|
859 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
860 | siztime=size(time); |
---|
861 | nbfield=siztime(1); |
---|
862 | nbfield2=siztime(2); |
---|
863 | indchosen=1; %%first pair selected by default |
---|
864 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
865 | dt=1; |
---|
866 | displ=''; |
---|
867 | index=0; |
---|
868 | numlist_a=[]; |
---|
869 | numlist_B=[]; |
---|
870 | %get all the time intervals in bursts |
---|
871 | displ_dt=1;%default |
---|
872 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
873 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
874 | for numod_b=(numod_a+1):nbfield2 |
---|
875 | index=index+1; |
---|
876 | numlist_a(index)=numod_a; |
---|
877 | numlist_b(index)=numod_b; |
---|
878 | if ~isempty(time) |
---|
879 | dt(numod_a,numod_b)=time(ref_i,numod_b)-time(ref_i,numod_a);%first time interval dt |
---|
880 | displ_dt(index)=dt(numod_a,numod_b); |
---|
881 | else |
---|
882 | displ_dt(index)=1; |
---|
883 | end |
---|
884 | end |
---|
885 | end |
---|
886 | [dtsort,indsort]=sort(displ_dt); |
---|
887 | if ~isempty(numlist_a) |
---|
888 | displ_num(1,:)=numlist_a(indsort); |
---|
889 | displ_num(2,:)=numlist_b(indsort); |
---|
890 | end |
---|
891 | displ_num(3,:)=0; |
---|
892 | displ_num(4,:)=0; |
---|
893 | set(handles.jtext,'Visible','Off') |
---|
894 | set(handles.first_j,'Visible','Off') |
---|
895 | set(handles.last_j,'Visible','Off') |
---|
896 | set(handles.incr_j,'Visible','Off') |
---|
897 | set(handles.nb_field2,'Visible','Off') |
---|
898 | set(handles.ref_j,'Visible','Off') |
---|
899 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
900 | for index=1:min(nbfield2-1,200) |
---|
901 | displ_num(1,index)=-floor(index/2); |
---|
902 | displ_num(2,index)=ceil(index/2); |
---|
903 | displ_num(3,index)=0; |
---|
904 | displ_num(4,index)=0; |
---|
905 | end |
---|
906 | set(handles.jtext,'Visible','On') |
---|
907 | set(handles.first_j,'Visible','On') |
---|
908 | set(handles.last_j,'Visible','On') |
---|
909 | set(handles.incr_j,'Visible','On') |
---|
910 | set(handles.nb_field2,'Visible','On') |
---|
911 | set(handles.ref_j,'Visible','On') |
---|
912 | if nbfield > 1 |
---|
913 | set(handles.itext,'Visible','On') |
---|
914 | set(handles.first_i,'Visible','On') |
---|
915 | set(handles.last_i,'Visible','On') |
---|
916 | set(handles.incr_i,'Visible','On') |
---|
917 | set(handles.nb_field,'Visible','On') |
---|
918 | set(handles.ref_i,'Visible','On') |
---|
919 | else |
---|
920 | set(handles.itext,'Visible','Off') |
---|
921 | set(handles.first_i,'Visible','Off') |
---|
922 | set(handles.last_i,'Visible','Off') |
---|
923 | set(handles.incr_i,'Visible','Off') |
---|
924 | set(handles.nb_field,'Visible','Off') |
---|
925 | set(handles.ref_i,'Visible','Off') |
---|
926 | end |
---|
927 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
928 | for index=1:200%min(nbfield-1,200) |
---|
929 | displ_num(1,index)=0; |
---|
930 | displ_num(2,index)=0; |
---|
931 | displ_num(3,index)=-floor(index/2); |
---|
932 | displ_num(4,index)=ceil(index/2); |
---|
933 | end |
---|
934 | set(handles.itext,'Visible','On') |
---|
935 | set(handles.first_i,'Visible','On') |
---|
936 | set(handles.last_i,'Visible','On') |
---|
937 | set(handles.incr_i,'Visible','On') |
---|
938 | set(handles.nb_field,'Visible','On') |
---|
939 | set(handles.ref_i,'Visible','On') |
---|
940 | if nbfield2 > 1 |
---|
941 | set(handles.jtext,'Visible','On') |
---|
942 | set(handles.first_j,'Visible','On') |
---|
943 | set(handles.last_j,'Visible','On') |
---|
944 | set(handles.incr_j,'Visible','On') |
---|
945 | set(handles.nb_field2,'Visible','On') |
---|
946 | set(handles.ref_j,'Visible','On') |
---|
947 | else |
---|
948 | set(handles.jtext,'Visible','Off') |
---|
949 | set(handles.first_j,'Visible','Off') |
---|
950 | set(handles.last_j,'Visible','Off') |
---|
951 | set(handles.incr_j,'Visible','Off') |
---|
952 | set(handles.nb_field2,'Visible','Off') |
---|
953 | set(handles.ref_j,'Visible','Off') |
---|
954 | end |
---|
955 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
956 | displ_num(1,1)=0; |
---|
957 | displ_num(2,1)=0; |
---|
958 | displ_num(3,1)=0; |
---|
959 | displ_num(4,1)=0; |
---|
960 | if nbfield > 1 |
---|
961 | set(handles.itext,'Visible','On') |
---|
962 | set(handles.first_i,'Visible','On') |
---|
963 | set(handles.last_i,'Visible','On') |
---|
964 | set(handles.incr_i,'Visible','On') |
---|
965 | set(handles.nb_field,'Visible','On') |
---|
966 | set(handles.ref_i,'Visible','On') |
---|
967 | else |
---|
968 | set(handles.itext,'Visible','Off') |
---|
969 | set(handles.first_i,'Visible','Off') |
---|
970 | set(handles.last_i,'Visible','Off') |
---|
971 | set(handles.incr_i,'Visible','Off') |
---|
972 | set(handles.nb_field,'Visible','Off') |
---|
973 | set(handles.ref_i,'Visible','Off') |
---|
974 | end |
---|
975 | if nbfield2 > 1 |
---|
976 | set(handles.jtext,'Visible','On') |
---|
977 | set(handles.first_j,'Visible','On') |
---|
978 | set(handles.last_j,'Visible','On') |
---|
979 | set(handles.incr_j,'Visible','On') |
---|
980 | set(handles.nb_field2,'Visible','On') |
---|
981 | set(handles.ref_j,'Visible','On') |
---|
982 | else |
---|
983 | set(handles.jtext,'Visible','Off') |
---|
984 | set(handles.first_j,'Visible','Off') |
---|
985 | set(handles.last_j,'Visible','Off') |
---|
986 | set(handles.incr_j,'Visible','Off') |
---|
987 | set(handles.nb_field2,'Visible','Off') |
---|
988 | set(handles.ref_j,'Visible','Off') |
---|
989 | end |
---|
990 | end |
---|
991 | set(handles.ListPairCiv1,'UserData',displ_num); |
---|
992 | find_netcpair_civ1( handles) |
---|
993 | find_netcpair_civ2(handles) |
---|
994 | |
---|
995 | %------------------------------------------------------------------------ |
---|
996 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
997 | % the field series set by first_i, incr, last_i |
---|
998 | function find_netcpair_civ1(handles) |
---|
999 | %------------------------------------------------------------------------ |
---|
1000 | set(gcf,'Pointer','watch') |
---|
1001 | %nomenclature types |
---|
1002 | filebase=get(handles.RootName,'String'); |
---|
1003 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
1004 | browse=get(handles.RootName,'UserData'); |
---|
1005 | compare_list=get(handles.ListCompareMode,'String'); |
---|
1006 | val=get(handles.ListCompareMode,'Value'); |
---|
1007 | compare=compare_list{val}; |
---|
1008 | if strcmp(compare,'displacement') |
---|
1009 | mode='displacement'; |
---|
1010 | else |
---|
1011 | mode_list=get(handles.ListPairMode,'String'); |
---|
1012 | mode_value=get(handles.ListPairMode,'Value'); |
---|
1013 | if isempty(mode_list) |
---|
1014 | return |
---|
1015 | end |
---|
1016 | mode=mode_list{mode_value}; |
---|
1017 | end |
---|
1018 | |
---|
1019 | % nomenclature type of the .nc files |
---|
1020 | nom_type_ima=[];%default |
---|
1021 | if isfield(browse,'nom_type_ima') |
---|
1022 | nom_type_ima=browse.nom_type_ima; |
---|
1023 | end |
---|
1024 | |
---|
1025 | %determine nom_type_nc: |
---|
1026 | nom_type_nc=[];%default |
---|
1027 | if isfield(browse,'nom_type_nc') |
---|
1028 | nom_type_nc=browse.nom_type_nc; |
---|
1029 | end |
---|
1030 | if isempty(nom_type_nc) |
---|
1031 | [nom_type_nc]=nomtype2pair(nom_type_ima,isequal(mode,'series(Di)'),isequal(mode,'series(Dj)')); |
---|
1032 | end |
---|
1033 | browse.nom_type_nc=nom_type_nc; |
---|
1034 | set(handles.RootName,'UserData',browse) |
---|
1035 | |
---|
1036 | %reads .nc subdirectoy and image numbers from the interface |
---|
1037 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
1038 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
1039 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
1040 | ref_j=0; |
---|
1041 | else |
---|
1042 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
1043 | end |
---|
1044 | time=get(handles.ImaDoc,'UserData');%get the set of times |
---|
1045 | if isempty(time) |
---|
1046 | time=[0 1]; |
---|
1047 | end |
---|
1048 | dt_unit=1000;%default |
---|
1049 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
1050 | |
---|
1051 | %eliminate the first pairs inconsistent with the position |
---|
1052 | if isempty(displ_num) |
---|
1053 | nbpair=0; |
---|
1054 | else |
---|
1055 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1056 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1057 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1058 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1059 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1060 | end |
---|
1061 | end |
---|
1062 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1063 | |
---|
1064 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
1065 | % be performed, while the result is needed for next steps. |
---|
1066 | displ_pair={''}; |
---|
1067 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
1068 | testpair=0; |
---|
1069 | % case with no checkciv1 operation, netcdf files need to exist for reading |
---|
1070 | if get(handles.CheckCiv1,'Value')==0 % |
---|
1071 | if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') |
---|
1072 | msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); |
---|
1073 | set(handles.ListPairCiv1,'String',{}); |
---|
1074 | return |
---|
1075 | end |
---|
1076 | for ipair=1:nbpair |
---|
1077 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1078 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1079 | select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist |
---|
1080 | end |
---|
1081 | % case of no displayed pair |
---|
1082 | if isequal(select,zeros(size(1:nbpair))) |
---|
1083 | if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0]) |
---|
1084 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1085 | num_i2=ref_i+ceil(browse.incr_pair(1)/2); |
---|
1086 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1087 | num_j2=ref_j+ceil(browse.incr_pair(2)/2); |
---|
1088 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ1); |
---|
1089 | select(1)=exist(filename,'file')==2; |
---|
1090 | testpair=1; |
---|
1091 | else |
---|
1092 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1093 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); |
---|
1094 | else |
---|
1095 | msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]); |
---|
1096 | end |
---|
1097 | set(handles.ListPairCiv1,'String',{''}); |
---|
1098 | %COMPLETER CAS STEREO |
---|
1099 | return |
---|
1100 | end |
---|
1101 | end |
---|
1102 | end |
---|
1103 | if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
1104 | if testpair |
---|
1105 | displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1106 | else |
---|
1107 | for ipair=1:nbpair |
---|
1108 | if select(ipair) |
---|
1109 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1110 | 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 |
---|
1111 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1112 | else |
---|
1113 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1114 | end |
---|
1115 | end |
---|
1116 | end |
---|
1117 | end |
---|
1118 | elseif isequal(mode,'series(Dj)')%|isequal(mode,'st_series(Dj)')% series on the j index |
---|
1119 | if testpair |
---|
1120 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; |
---|
1121 | else |
---|
1122 | for ipair=1:nbpair |
---|
1123 | if select(ipair) |
---|
1124 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1125 | 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 |
---|
1126 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1127 | end |
---|
1128 | elseif testpair |
---|
1129 | displ_pair{1}=['Dj= ' num2str(-floor(browse.incr_pair(2)/2)) '|' num2str(ceil(browse.incr_pair(2)/2))]; |
---|
1130 | else |
---|
1131 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1132 | end |
---|
1133 | end |
---|
1134 | end |
---|
1135 | elseif isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')%case of pairs |
---|
1136 | for ipair=1:nbpair |
---|
1137 | if select(ipair) |
---|
1138 | 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 |
---|
1139 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1140 | ' :dt= ' num2str(dt*1000)]; |
---|
1141 | else |
---|
1142 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1143 | end |
---|
1144 | end |
---|
1145 | elseif isequal(mode,'displacement') |
---|
1146 | displ_pair={'Di=Dj=0'}; |
---|
1147 | end |
---|
1148 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
1149 | ichoice=find(select,1); |
---|
1150 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
1151 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
1152 | if initial>nbpair |
---|
1153 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1154 | end |
---|
1155 | if numel(select)>=initial && ~isequal(select(initial),1) |
---|
1156 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
1157 | end |
---|
1158 | |
---|
1159 | %set(handles.ListPairCiv2,'String',displ_pair'); |
---|
1160 | initial=get(handles.ListPairCiv2,'Value'); |
---|
1161 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
1162 | if ichoice <= length(displ_pair') |
---|
1163 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
1164 | else |
---|
1165 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
1166 | end |
---|
1167 | end |
---|
1168 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
1169 | set(gcf,'Pointer','arrow') |
---|
1170 | |
---|
1171 | %------------------------------------------------------------------------ |
---|
1172 | % determine the menu for checkciv2 pairs depending on the existing netcdf file at the |
---|
1173 | %middle of the series set by first_i, incr, last_i |
---|
1174 | function find_netcpair_civ2(handles) |
---|
1175 | %------------------------------------------------------------------------ |
---|
1176 | set(gcf,'Pointer','watch') |
---|
1177 | %nomenclature types |
---|
1178 | filebase=get(handles.RootName,'String'); |
---|
1179 | [filepath,Nme,ext_dir]=fileparts(filebase); |
---|
1180 | browse=get(handles.RootName,'UserData'); |
---|
1181 | compare_list=get(handles.ListCompareMode,'String'); |
---|
1182 | val=get(handles.ListCompareMode,'Value'); |
---|
1183 | compare=compare_list{val}; |
---|
1184 | if strcmp(compare,'displacement') |
---|
1185 | mode='displacement'; |
---|
1186 | else |
---|
1187 | mode_list=get(handles.ListPairMode,'String'); |
---|
1188 | if isempty(mode_list) |
---|
1189 | msgbox_uvmat('ERROR','please enter an input image or netcdf file') |
---|
1190 | return |
---|
1191 | end |
---|
1192 | mode_value=get(handles.ListPairMode,'Value'); |
---|
1193 | mode=mode_list{mode_value}; |
---|
1194 | end |
---|
1195 | |
---|
1196 | % nomenclature type of the .nc files |
---|
1197 | nom_type_ima='ima_num';%default |
---|
1198 | if isfield(browse,'nom_type_ima') |
---|
1199 | nom_type_ima=browse.nom_type_ima; |
---|
1200 | end |
---|
1201 | nom_type_nc='_i1-i2';%default |
---|
1202 | if isfield(browse,'nom_type_nc') |
---|
1203 | nom_type_nc=browse.nom_type_nc; |
---|
1204 | end |
---|
1205 | 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') |
---|
1206 | nom_type_nc='netc_old';%nom_type for the netcdf files |
---|
1207 | elseif isequal(nom_type_ima,'none')||isequal(nom_type_nc,'none') |
---|
1208 | nom_type_nc='none'; |
---|
1209 | elseif isequal(nom_type_ima,'avi')||isequal(nom_type_ima,'_i')||isequal(nom_type_ima,'ima_num')||isequal(nom_type_nc,'_i1-i2') |
---|
1210 | nom_type_nc='_i1-i2'; |
---|
1211 | else |
---|
1212 | if isequal(mode,'series(Di)')%|isequal(mode,'st_series(Di)') |
---|
1213 | nom_type_nc='_i1-i2_j'; % PIV in volume |
---|
1214 | else |
---|
1215 | nom_type_nc='_i_j1-j2'; |
---|
1216 | end |
---|
1217 | end |
---|
1218 | browse.nom_type_nc=nom_type_nc; |
---|
1219 | set(handles.RootName,'UserData',browse) |
---|
1220 | |
---|
1221 | %reads .nc subdirectory and image numbers from the interface |
---|
1222 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data |
---|
1223 | subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data |
---|
1224 | % first_i=str2num(get(handles.first_i,'String')); |
---|
1225 | % last_i=str2num(get(handles.last_i,'String')); |
---|
1226 | % incr=str2num(get(handles.incr_i,'String')); |
---|
1227 | % num1=first_i:incr:last_i; |
---|
1228 | % if isempty(num1) |
---|
1229 | % set(handles.ListPairCiv2,'Value',1); |
---|
1230 | % set(handles.ListPairCiv2,'String',{''}); |
---|
1231 | % return |
---|
1232 | % end |
---|
1233 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
1234 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
1235 | ref_j=0; |
---|
1236 | else |
---|
1237 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
1238 | end |
---|
1239 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
1240 | if isempty(time) |
---|
1241 | time=[0 1];%default |
---|
1242 | end |
---|
1243 | %dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file |
---|
1244 | %dt_unit=1000; |
---|
1245 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
1246 | |
---|
1247 | |
---|
1248 | %eliminate the first pairs inconsistent with the position |
---|
1249 | if isempty(displ_num) |
---|
1250 | nbpair=0; |
---|
1251 | else |
---|
1252 | nbpair=length(displ_num(1,:));%nbre of displayed pairs |
---|
1253 | if isequal(mode,'series(Di)')% | isequal(mode,'st_series(Di)') |
---|
1254 | nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index |
---|
1255 | elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1256 | nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index |
---|
1257 | end |
---|
1258 | end |
---|
1259 | nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 |
---|
1260 | |
---|
1261 | %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not |
---|
1262 | % be performed, while the result is needed for next steps. |
---|
1263 | displ_pair={''}; %default |
---|
1264 | select=ones(size(1:nbpair));%default =1 for numbers of displayed pairs |
---|
1265 | if get(handles.CheckCiv2,'Value')==0 & get(handles.CheckCiv1,'Value')==0 & get(handles.CheckFix1,'Value')==0 & get(handles.CheckPatch1,'Value')==0%&... |
---|
1266 | if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') |
---|
1267 | errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) |
---|
1268 | set(handles.ListPairCiv2,'Value',1); |
---|
1269 | set(handles.ListPairCiv2,'String',{''}); |
---|
1270 | return |
---|
1271 | end |
---|
1272 | for ipair=1:nbpair |
---|
1273 | filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... |
---|
1274 | ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); |
---|
1275 | select(ipair)=exist(filename,'file')==2; |
---|
1276 | end |
---|
1277 | if isequal(select,zeros(size(1:nbpair))) |
---|
1278 | if isfield(browse,'incr_pair') |
---|
1279 | num_i1=ref_i-floor(browse.incr_pair(1)/2); |
---|
1280 | num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); |
---|
1281 | num_j1=ref_j-floor(browse.incr_pair(2)/2); |
---|
1282 | num_j2=ref_j+floor((browse.incr_pair(2)+1)/2); |
---|
1283 | filename=name_generator(filebase,num_i1,num_j1,'.nc',nom_type_nc,1,num_i2,num_j2,subdir_civ2); |
---|
1284 | select(1)=exist(filename,'file')==2; |
---|
1285 | else |
---|
1286 | if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') |
---|
1287 | errordlg(['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) |
---|
1288 | else |
---|
1289 | errordlg(['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2]) |
---|
1290 | end |
---|
1291 | set(handles.ListPairCiv2,'Value',1); |
---|
1292 | set(handles.ListPairCiv2,'String',{''}); |
---|
1293 | return |
---|
1294 | end |
---|
1295 | end |
---|
1296 | end |
---|
1297 | if isequal(mode,'series(Di)') % | isequal(mode,'st_series(Di)') |
---|
1298 | for ipair=1:nbpair |
---|
1299 | if select(ipair) |
---|
1300 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1301 | 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 |
---|
1302 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1303 | end |
---|
1304 | else |
---|
1305 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1306 | end |
---|
1307 | end |
---|
1308 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') % series on the j index |
---|
1309 | for ipair=1:nbpair |
---|
1310 | if select(ipair) |
---|
1311 | if size(time,1)>=ref_i+displ_num(4,ipair) && size(time,2)>=ref_j+displ_num(2,ipair) |
---|
1312 | 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 |
---|
1313 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; |
---|
1314 | end |
---|
1315 | else |
---|
1316 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1317 | end |
---|
1318 | end |
---|
1319 | elseif isequal(mode,'pair j1-j2')% | isequal(mode,'st_pair j1-j2') %case of pairs |
---|
1320 | for ipair=1:nbpair |
---|
1321 | if select(ipair) |
---|
1322 | 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 |
---|
1323 | displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... |
---|
1324 | ' :dt= ' num2str(dt*1000)]; |
---|
1325 | else |
---|
1326 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
1327 | end |
---|
1328 | end |
---|
1329 | elseif isequal(mode,'displacement') |
---|
1330 | displ_pair={'Di=Dj=0'}; |
---|
1331 | end |
---|
1332 | val=get(handles.ListPairCiv2,'Value'); |
---|
1333 | ichoice=find(select,1); |
---|
1334 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
1335 | if get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0 |
---|
1336 | val=ichoice;% first valid pair proposed by default in the menu |
---|
1337 | end |
---|
1338 | if val>length(displ_pair') |
---|
1339 | set(handles.ListPairCiv2,'Value',1);% first valid pair proposed by default in the menu |
---|
1340 | else |
---|
1341 | set(handles.ListPairCiv2,'Value',val); |
---|
1342 | end |
---|
1343 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
1344 | set(gcf,'Pointer','arrow') |
---|
1345 | |
---|
1346 | |
---|
1347 | |
---|
1348 | |
---|
1349 | %------------------------------------------------------------------------ |
---|
1350 | % --- Executes on selection change in ListPairCiv1. |
---|
1351 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
1352 | %------------------------------------------------------------------------ |
---|
1353 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
1354 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
1355 | index_pair=get(handles.ListPairCiv1,'Value'); |
---|
1356 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
1357 | % num_a=displ_num(1,index_pair); |
---|
1358 | % num_b=displ_num(2,index_pair); |
---|
1359 | list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs |
---|
1360 | if index_pair<=length(list_pair2) |
---|
1361 | set(handles.ListPairCiv2,'Value',index_pair); |
---|
1362 | end |
---|
1363 | |
---|
1364 | %update first_i and last_i according to the chosen image pairs |
---|
1365 | mode_list=get(handles.ListPairMode,'String'); |
---|
1366 | mode_value=get(handles.ListPairMode,'Value'); |
---|
1367 | mode=mode_list{mode_value}; |
---|
1368 | if isequal(mode,'series(Di)') |
---|
1369 | first_i=str2double(get(handles.first_i,'String')); |
---|
1370 | last_i=str2double(get(handles.last_i,'String')); |
---|
1371 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
1372 | num1=first_i:incr_i:last_i; |
---|
1373 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
1374 | if ~isnan(lastfield) |
---|
1375 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1376 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
1377 | num1=num1(test_find); |
---|
1378 | end |
---|
1379 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1380 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1381 | elseif isequal(mode,'series(Dj)') |
---|
1382 | first_j=str2double(get(handles.first_j,'String')); |
---|
1383 | last_j=str2double(get(handles.last_j,'String')); |
---|
1384 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
1385 | num_j=first_j:incr_j:last_j; |
---|
1386 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
1387 | if ~isnan(lastfield2) |
---|
1388 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1389 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
1390 | num1=num_j(test_find); |
---|
1391 | end |
---|
1392 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1393 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1394 | end |
---|
1395 | |
---|
1396 | %------------------------------------------------------------------------ |
---|
1397 | % --- Executes on selection change in ListPairCiv2. |
---|
1398 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
1399 | %------------------------------------------------------------------------ |
---|
1400 | index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu |
---|
1401 | |
---|
1402 | %update first_i and last_i according to the chosen image pairs |
---|
1403 | mode_list=get(handles.ListPairMode,'String'); |
---|
1404 | mode_value=get(handles.ListPairMode,'Value'); |
---|
1405 | mode=mode_list{mode_value}; |
---|
1406 | if isequal(mode,'series(Di)') |
---|
1407 | first_i=str2double(get(handles.first_i,'String')); |
---|
1408 | last_i=str2double(get(handles.last_i,'String')); |
---|
1409 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
1410 | num1=first_i:incr_i:last_i; |
---|
1411 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
1412 | if ~isnan(lastfield) |
---|
1413 | test_find=(num1-floor(index_pair/2)*ones(size(num1))>0)& ... |
---|
1414 | (num1+ceil(index_pair/2)*ones(size(num1))<=lastfield); |
---|
1415 | num1=num1(test_find); |
---|
1416 | end |
---|
1417 | set(handles.first_i,'String',num2str(num1(1))); |
---|
1418 | set(handles.last_i,'String',num2str(num1(end))); |
---|
1419 | elseif isequal(mode,'series(Dj)') |
---|
1420 | first_j=str2double(get(handles.first_j,'String')); |
---|
1421 | last_j=str2double(get(handles.last_j,'String')); |
---|
1422 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
1423 | num_j=first_j:incr_j:last_j; |
---|
1424 | lastfield2=str2double(get(handles.nb_field2,'String')); |
---|
1425 | if ~isnan(lastfield2) |
---|
1426 | test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ... |
---|
1427 | (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2); |
---|
1428 | num1=num_j(test_find); |
---|
1429 | end |
---|
1430 | set(handles.first_j,'String',num2str(num1(1))); |
---|
1431 | set(handles.last_j,'String',num2str(num1(end))); |
---|
1432 | end |
---|
1433 | |
---|
1434 | %------------------------------------------------------------------------ |
---|
1435 | % --- Executes on button press in RUN: processing on local computer |
---|
1436 | function RUN_Callback(hObject, eventdata, handles) |
---|
1437 | %------------------------------------------------------------------------ |
---|
1438 | set(handles.RUN, 'Enable','Off') |
---|
1439 | set(handles.RUN,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1440 | batch=0; |
---|
1441 | errormsg=launch_jobs(hObject, eventdata, handles,batch); |
---|
1442 | set(handles.RUN, 'Enable','On') |
---|
1443 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
1444 | |
---|
1445 | % start status callback to visualise results |
---|
1446 | if ~isempty(errormsg) |
---|
1447 | display(errormsg) |
---|
1448 | msgbox_uvmat('ERROR',errormsg) |
---|
1449 | elseif isfield(handles,'status') %&& ~isequal(get(handles.ListPairMode,'Value'),3) |
---|
1450 | set(handles.status,'Value',1);%suppress status display |
---|
1451 | status_Callback(hObject, eventdata, handles) |
---|
1452 | end |
---|
1453 | |
---|
1454 | %------------------------------------------------------------------------ |
---|
1455 | % --- Executes on button press in BATCH: remote processing |
---|
1456 | function BATCH_Callback(hObject, eventdata, handles) |
---|
1457 | % ----------------------------------------------------------------------- |
---|
1458 | set(handles.BATCH, 'Enable','Off') |
---|
1459 | set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784]) |
---|
1460 | batch=1; |
---|
1461 | errormsg=launch_jobs(hObject, eventdata, handles, batch); |
---|
1462 | set(handles.BATCH, 'Enable','On') |
---|
1463 | set(handles.BATCH,'BackgroundColor',[1 0 0]) |
---|
1464 | |
---|
1465 | % start status callback to visualise results |
---|
1466 | if ~isempty(errormsg) |
---|
1467 | display(errormsg) |
---|
1468 | msgbox_uvmat('ERROR',errormsg) |
---|
1469 | elseif isfield(handles,'status') |
---|
1470 | set(handles.status,'Value',1);%suppress status display |
---|
1471 | status_Callback(hObject, eventdata, handles) |
---|
1472 | end |
---|
1473 | |
---|
1474 | %------------------------------------------------------------------------ |
---|
1475 | % --- Lauch command called by RUN and BATCH: remote processing |
---|
1476 | function errormsg=launch_jobs(hObject, eventdata, handles, batch) |
---|
1477 | %----------------------------------------------------------------------- |
---|
1478 | errormsg='';%default |
---|
1479 | |
---|
1480 | %%read the civ GUI |
---|
1481 | Param=read_GUI(handles.civ); |
---|
1482 | %% check the selected list of operations: |
---|
1483 | operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
1484 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
1485 | |
---|
1486 | index_first=find(box_test==1,1); |
---|
1487 | if isempty(index_first) |
---|
1488 | errormsg='no selected operation'; |
---|
1489 | return |
---|
1490 | end |
---|
1491 | index_last=find(box_test==1,1,'last'); |
---|
1492 | box_used=box_test(index_first : index_last); |
---|
1493 | [box_missing,ind_missing]=min(box_used); |
---|
1494 | if isequal(box_missing,0); %there is a missing step in the sequence of operations |
---|
1495 | errormsg=['missing' cell2mat(operations(ind_missing))]; |
---|
1496 | return |
---|
1497 | end |
---|
1498 | |
---|
1499 | %% check mask if selecetd |
---|
1500 | %could be included in get_mask callback ? |
---|
1501 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
1502 | maskname=get(handles.txt_MaskName,'String'); |
---|
1503 | if ~exist(maskname,'file') |
---|
1504 | get_mask_civ1_Callback(hObject, eventdata, handles); |
---|
1505 | end |
---|
1506 | end |
---|
1507 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
1508 | maskname=get(handles.txt_MaskName,'String'); |
---|
1509 | if ~exist(maskname,'file') |
---|
1510 | get_mask_fix1_Callback(hObject, eventdata, handles); |
---|
1511 | end |
---|
1512 | end |
---|
1513 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
1514 | maskname=get(handles.txt_Mask,'String'); |
---|
1515 | if ~exist(maskname,'file') |
---|
1516 | get_mask_civ2_Callback(hObject, eventdata, handles); |
---|
1517 | end |
---|
1518 | end |
---|
1519 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
1520 | maskname=get(handles.txt_MaskName,'String'); |
---|
1521 | if ~exist(maskname,'file') |
---|
1522 | get_mask_fix2_Callback(hObject, eventdata, handles); |
---|
1523 | end |
---|
1524 | end |
---|
1525 | |
---|
1526 | %% reinitialise status callback |
---|
1527 | if isfield(handles,'status') |
---|
1528 | set(handles.status,'Value',0);%suppress status display |
---|
1529 | status_Callback(hObject, eventdata, handles) |
---|
1530 | end |
---|
1531 | |
---|
1532 | %% set the list of files and check them |
---|
1533 | display('checking the files...') |
---|
1534 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
1535 | if ~isempty(errormsg) |
---|
1536 | return |
---|
1537 | end |
---|
1538 | [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,xx,yy,compare]=... |
---|
1539 | set_civ_filenames(handles,ref_i,ref_j,box_test); |
---|
1540 | % ADDED |
---|
1541 | [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention) |
---|
1542 | %ADDED |
---|
1543 | set(handles.civ,'UserData',filecell);%store for futur use of status callback |
---|
1544 | if isempty(filecell)% (error message displayed in fct set_civ_filenames) |
---|
1545 | return |
---|
1546 | end |
---|
1547 | nbfield=numel(num1_civ1); |
---|
1548 | nbslice=numel(num_a_civ1); |
---|
1549 | |
---|
1550 | %% read the PARAM.xml file to get the binaries (and batch_mode if batch) |
---|
1551 | path_civ=fileparts(which('civ')); %path to the source directory of uvmat |
---|
1552 | xmlfile='PARAM.xml'; |
---|
1553 | if exist(xmlfile,'file')% search parameter xml file in the whole matlab path |
---|
1554 | t=xmltree(xmlfile); |
---|
1555 | s=convert(t); |
---|
1556 | else |
---|
1557 | errormsg=['no file ' xmlfile]; |
---|
1558 | return |
---|
1559 | end |
---|
1560 | |
---|
1561 | test_interp=0; %eviter les variables test_ (LG) |
---|
1562 | |
---|
1563 | if batch |
---|
1564 | if isfield(s,'BatchParam') |
---|
1565 | Param.xml=s.BatchParam; |
---|
1566 | if isfield(Param.xml,'BatchMode') |
---|
1567 | batch_mode=Param.xml.BatchMode; |
---|
1568 | if ~ismember(batch_mode,{'sge','oar'}) |
---|
1569 | errormsg=['batch mode ' batch_mode ' not supported by UVMAT']; |
---|
1570 | return |
---|
1571 | end |
---|
1572 | end |
---|
1573 | else |
---|
1574 | errormsg='no batch civ binaries defined in PARAM.xml'; |
---|
1575 | return |
---|
1576 | end |
---|
1577 | else % run |
---|
1578 | if isfield(s,'RunParam') |
---|
1579 | Param.xml=s.RunParam; |
---|
1580 | else |
---|
1581 | msgbox_uvmat('ERROR','no run civ binaries defined in PARAM.xml') |
---|
1582 | return |
---|
1583 | end |
---|
1584 | end |
---|
1585 | |
---|
1586 | %% check batch mode supported |
---|
1587 | if batch |
---|
1588 | switch batch_mode |
---|
1589 | case 'sge' |
---|
1590 | test_command='qstat'; |
---|
1591 | case 'oar' |
---|
1592 | test_command='oarstat'; |
---|
1593 | end |
---|
1594 | [s,w]=system(test_command); |
---|
1595 | if ~isequal(s,0) |
---|
1596 | msgbox_uvmat('ERROR',[batch_mode ' batch system not available']) |
---|
1597 | return |
---|
1598 | end |
---|
1599 | end |
---|
1600 | |
---|
1601 | %% check if the binaries exist |
---|
1602 | if isequal(get(handles.Matlab,'checked'),'on') |
---|
1603 | CivMode='Matlab'; |
---|
1604 | else |
---|
1605 | CivMode='CivX'; |
---|
1606 | end |
---|
1607 | binary_list={}; |
---|
1608 | switch CivMode |
---|
1609 | case 'CivX' |
---|
1610 | binary_list={'Civ1Bin','Civ2Bin','PatchBin','FixBin'}; |
---|
1611 | case 'CivAll' |
---|
1612 | binary_list={'Civ'}; |
---|
1613 | case 'Matlab' |
---|
1614 | if batch |
---|
1615 | % vérifier Matlab installé sur le cluster |
---|
1616 | % difficile a faire a priori |
---|
1617 | end |
---|
1618 | end |
---|
1619 | for bin_name=binary_list |
---|
1620 | if isfield(Param.xml,bin_name{1}) |
---|
1621 | if ~exist(Param.xml.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml |
---|
1622 | fullname=fullfile(path_civ,Param.xml.(bin_name{1})); |
---|
1623 | if exist(fullname,'file') |
---|
1624 | Param.xml.(bin_name{1})=fullname; |
---|
1625 | else |
---|
1626 | msgbox_uvmat('ERROR',['Binary ' Param.xml.(bin_name{1}) ' defined in PARAM.xml does not exist']) |
---|
1627 | return |
---|
1628 | end |
---|
1629 | else |
---|
1630 | [path,name,ext]=fileparts(Param.xml.(bin_name{1})); |
---|
1631 | currentdir=pwd; |
---|
1632 | cd(path); |
---|
1633 | binpath=pwd;%path of the binary |
---|
1634 | Param.xml.(bin_name{1})=fullfile(binpath,[name ext]); |
---|
1635 | % display(Param.xml.(bin_name{1})); |
---|
1636 | cd(currentdir); |
---|
1637 | end |
---|
1638 | |
---|
1639 | end |
---|
1640 | end |
---|
1641 | |
---|
1642 | display('files OK, processing...') |
---|
1643 | |
---|
1644 | |
---|
1645 | %% MAIN LOOP |
---|
1646 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
1647 | |
---|
1648 | super_cmd=[]; |
---|
1649 | batch_file_list=[]; |
---|
1650 | |
---|
1651 | for ifile=1:nbfield |
---|
1652 | for j=1:nbslice |
---|
1653 | % initiate system command |
---|
1654 | switch CivMode |
---|
1655 | case 'CivX' |
---|
1656 | if isunix % check: necessaire aussi en RUN? |
---|
1657 | cmd=['#!/bin/bash \n '... |
---|
1658 | '#$ -cwd \n '... |
---|
1659 | 'hostname && date \n '... |
---|
1660 | 'umask 002 \n'];%allow writting access to created files for user group |
---|
1661 | else |
---|
1662 | cmd=[]; |
---|
1663 | end |
---|
1664 | case 'CivAll' |
---|
1665 | % if CivAll |
---|
1666 | CivAllxml=xmltree;% xml contents, all parameters |
---|
1667 | CivAllCmd=''; |
---|
1668 | CivAllxml=set(CivAllxml,1,'name','CivDoc'); |
---|
1669 | end |
---|
1670 | |
---|
1671 | |
---|
1672 | % define output file name |
---|
1673 | if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 |
---|
1674 | OutputFile=filecell.nc.civ2{ifile,j}; |
---|
1675 | else |
---|
1676 | OutputFile=filecell.nc.civ1{ifile,j}; |
---|
1677 | end |
---|
1678 | OutputFile=regexprep(OutputFile,'.nc',''); |
---|
1679 | |
---|
1680 | if Param.CheckCiv1 |
---|
1681 | % read image-dependent parameters |
---|
1682 | Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; |
---|
1683 | Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; |
---|
1684 | Param.Civ1.Dt=(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j))); |
---|
1685 | Param.Civ1.T0=((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2); |
---|
1686 | Param.Civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE? |
---|
1687 | Param.Civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);% |
---|
1688 | Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
1689 | Param.Civ1.pxcmy=1; |
---|
1690 | |
---|
1691 | A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
1692 | sizim=size(A); |
---|
1693 | Param.Civ1.npx=(sizim(2)); |
---|
1694 | Param.Civ1.npy=(sizim(1)); |
---|
1695 | %TODO : civ should not need npx and npy |
---|
1696 | |
---|
1697 | % read mask parameters |
---|
1698 | if Param.Civ1.CheckMask % the lines below should be changed with the new gui |
---|
1699 | %matbe they when check_mask the Maskname is read |
---|
1700 | if exist(Param.Civ1.MaskName,'file') |
---|
1701 | Param.Civ1.MaskFlag='y'; |
---|
1702 | else |
---|
1703 | maskbase=[filecell.filebase '_' Param.Civ1.MaskName]; % |
---|
1704 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
1705 | num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1; |
---|
1706 | Param.Civ1.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1707 | if exist(Param.Civ1.MaskName,'file') |
---|
1708 | Param.Civ1.maskflag='y'; |
---|
1709 | else |
---|
1710 | Param.Civ1.MaskName='noFile use default'; |
---|
1711 | Param.Civ1.MaskFlag='n'; |
---|
1712 | end |
---|
1713 | end |
---|
1714 | else |
---|
1715 | Param.Civ1.MaskName='noFile use default'; |
---|
1716 | Param.Civ1.MaskFlag='n'; |
---|
1717 | end |
---|
1718 | |
---|
1719 | % read grid parameters= |
---|
1720 | if Param.Civ1.CheckGrid |
---|
1721 | Param.Civ1.GridFlag='y'; |
---|
1722 | if isequal(Param.Civ1.GridName(end-3:end),'grid') |
---|
1723 | nbslice_grid=str2double(Param.Civ1.GridName(1:end-4)); % |
---|
1724 | if ~isnan(nbslice_grid) |
---|
1725 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
1726 | Param.Civ1.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
1727 | if ~exist(Param.Civ1.GridName,'file') |
---|
1728 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
1729 | end |
---|
1730 | elseif ~exist(Param.Civ1.GridName,'file') |
---|
1731 | msgbox_uvmat('ERROR','grid file absent for civ1') |
---|
1732 | end |
---|
1733 | end |
---|
1734 | else |
---|
1735 | Param.Civ1.GridName='noFile use default'; |
---|
1736 | Param.Civ1.GridFlag='n'; |
---|
1737 | end |
---|
1738 | |
---|
1739 | % send command |
---|
1740 | switch CivMode |
---|
1741 | case 'CivX' |
---|
1742 | cmd=[cmd... |
---|
1743 | cmd_civ1(filecell.nc.civ1{ifile,j},Param) '\n']; |
---|
1744 | case 'CivAll' |
---|
1745 | CivAllCmd=[CivAllCmd ' civ1 ']; |
---|
1746 | str=CIV1_CMD_Unified(filecell.nc.civ1{ifile,j},'',Param.Civ1); |
---|
1747 | fieldnames=fields(str); |
---|
1748 | [CivAllxml,uid_civ1]=add(CivAllxml,1,'element','civ1'); |
---|
1749 | for ilist=1:length(fieldnames) |
---|
1750 | val=eval(['str.' fieldnames{ilist}]); |
---|
1751 | if ischar(val) |
---|
1752 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ1,'element',fieldnames{ilist}); |
---|
1753 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1754 | end |
---|
1755 | end |
---|
1756 | end |
---|
1757 | end |
---|
1758 | |
---|
1759 | if Param.CheckFix1 |
---|
1760 | switch CivMode |
---|
1761 | case 'CivX' |
---|
1762 | cmd=[cmd... |
---|
1763 | cmd_fix(filecell.nc.civ1{ifile,j},Param,'Fix1') '\n']; |
---|
1764 | case 'CivAll' |
---|
1765 | fix1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
1766 | fix1.fi1=num2str(param.fix1.flagindex1(1)); |
---|
1767 | fix1.fi2=num2str(param.fix1.flagindex1(2)); |
---|
1768 | fix1.fi3=num2str(param.fix1.flagindex1(3)); |
---|
1769 | fix1.threshC=num2str(param.fix1.thresh_vecC1); |
---|
1770 | fix1.threshV=num2str(param.fix1.thresh_vel1); |
---|
1771 | fieldnames=fields(fix1); |
---|
1772 | [CivAllxml,uid_fix1]=add(CivAllxml,1,'element','fix1'); |
---|
1773 | for ilist=1:length(fieldnames) |
---|
1774 | val=eval(['fix1.' fieldnames{ilist}]); |
---|
1775 | if ischar(val) |
---|
1776 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix1,'element',fieldnames{ilist}); |
---|
1777 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1778 | end |
---|
1779 | end |
---|
1780 | CivAllCmd=[CivAllCmd ' fix1 ']; |
---|
1781 | end |
---|
1782 | end |
---|
1783 | |
---|
1784 | %CheckPatch1 |
---|
1785 | if Param.CheckPatch1==1 |
---|
1786 | switch CivMode |
---|
1787 | case 'CivX' |
---|
1788 | cmd=[cmd... |
---|
1789 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch1') '\n']; |
---|
1790 | case 'CivAll' |
---|
1791 | patch1.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
1792 | patch1.nopt=subdomain_patch1; |
---|
1793 | patch1.maxdiff=thresh_patch1; |
---|
1794 | patch1.ro=rho_patch1; |
---|
1795 | test_grid=get(handles.get_gridpatch1,'Value'); |
---|
1796 | if test_grid |
---|
1797 | patch1.gridflag='y'; |
---|
1798 | gridname=get(handles.grid_patch1,'String'); |
---|
1799 | if isequal(gridname(end-3:end),'grid') |
---|
1800 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
1801 | if ~isnan(nbslice_grid) |
---|
1802 | num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1; |
---|
1803 | patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
1804 | if ~exist(patch1.gridPatch,'file') |
---|
1805 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
1806 | end |
---|
1807 | elseif exist(gridname,'file') |
---|
1808 | patch1.gridPatch=gridname; |
---|
1809 | else |
---|
1810 | msgbox_uvmat('ERROR','grid file absent for patch1') |
---|
1811 | end |
---|
1812 | end |
---|
1813 | else |
---|
1814 | patch1.gridPatch='none'; |
---|
1815 | patch1.gridflag='n'; |
---|
1816 | patch1.m=nx_patch1; |
---|
1817 | patch1.n=ny_patch1; |
---|
1818 | end |
---|
1819 | patch1.convectFlow='n'; |
---|
1820 | fieldnames=fields(patch1); |
---|
1821 | [CivAllxml,uid_patch1]=add(CivAllxml,1,'element','patch1'); |
---|
1822 | for ilist=1:length(fieldnames) |
---|
1823 | val=eval(['patch1.' fieldnames{ilist}]); |
---|
1824 | if ischar(val) |
---|
1825 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch1,'element',fieldnames{ilist}); |
---|
1826 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1827 | end |
---|
1828 | end |
---|
1829 | CivAllCmd=[CivAllCmd ' patch1 ']; |
---|
1830 | end |
---|
1831 | end |
---|
1832 | if Param.CheckCiv2==1 |
---|
1833 | Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; |
---|
1834 | Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; |
---|
1835 | Param.Civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j))); |
---|
1836 | Param.Civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2); |
---|
1837 | Param.Civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc); |
---|
1838 | Param.Civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc); |
---|
1839 | Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; |
---|
1840 | Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' |
---|
1841 | Param.Civ2.pxcmx=1; %velocities are expressed in pixel dispalcement |
---|
1842 | Param.Civ2.pxcmy=1; |
---|
1843 | if Param.Civ2.CheckMask |
---|
1844 | maskdispl=get(handles.txt_Mask,'String'); |
---|
1845 | if exist(maskdispl,'file') |
---|
1846 | Param.Civ2.MaskName=maskdispl; |
---|
1847 | Param.Civ2.MaskFlag='y'; |
---|
1848 | else |
---|
1849 | maskbase=[filecell.filebase '_' maskdispl]; % |
---|
1850 | nbslice_mask=str2double(maskdispl(1:end-4)); % |
---|
1851 | num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1; |
---|
1852 | Param.Civ2.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i'); |
---|
1853 | if exist(Param.Civ2.MaskName,'file') |
---|
1854 | Param.Civ2.MaskFlag='y'; |
---|
1855 | else |
---|
1856 | Param.Civ2.MaskName='noFile use default'; |
---|
1857 | Param.Civ2.MaskFlag='n'; |
---|
1858 | end |
---|
1859 | end |
---|
1860 | else |
---|
1861 | Param.Civ2.MaskName='noFile use default'; |
---|
1862 | Param.Civ2.MaskFlag='n'; |
---|
1863 | end |
---|
1864 | gridname=get(handles.txt_GridName,'String'); |
---|
1865 | if numel(gridname)>=4 && isequal(gridname(end-3:end),'grid') |
---|
1866 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
1867 | if ~isnan(nbslice_grid) |
---|
1868 | Param.Civ2.GridFlag='y'; |
---|
1869 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
1870 | Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
1871 | if exist(Param.Civ2.GridName,'file') |
---|
1872 | Param.Civ2.GridFlag='y'; |
---|
1873 | else |
---|
1874 | Param.Civ2.GridName='noFile use default'; |
---|
1875 | Param.Civ2.GridFlag='n'; |
---|
1876 | end |
---|
1877 | elseif exist(gridname,'file') |
---|
1878 | Param.Civ2.GridFlag='y'; |
---|
1879 | else |
---|
1880 | Param.Civ2.GridName='noFile use default'; |
---|
1881 | Param.Civ2.GridFlag='n'; |
---|
1882 | end |
---|
1883 | else |
---|
1884 | Param.Civ2.GridName='noFile use default'; |
---|
1885 | Param.Civ2.GridFlag='n'; |
---|
1886 | end |
---|
1887 | A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size |
---|
1888 | sizim=size(A); |
---|
1889 | Param.Civ2.npx=(sizim(2)); |
---|
1890 | Param.Civ2.npy=(sizim(1)); |
---|
1891 | |
---|
1892 | switch CivMode |
---|
1893 | case 'CivX' |
---|
1894 | cmd=[cmd... |
---|
1895 | cmd_civ2(filecell.nc.civ2{ifile,j},Param) '\n']; |
---|
1896 | case 'CivAll' |
---|
1897 | CivAllCmd=[CivAllCmd ' civ2 ']; |
---|
1898 | str=CIV2_CMD_Unified(filecell.nc.civ2{ifile,j},'',Param.Civ2); |
---|
1899 | fieldnames=fields(str); |
---|
1900 | [CivAllxml,uid_civ2]=add(CivAllxml,1,'element','civ2'); |
---|
1901 | for ilist=1:length(fieldnames) |
---|
1902 | val=eval(['str.' fieldnames{ilist}]); |
---|
1903 | if ischar(val) |
---|
1904 | [CivAllxml,uid_t]=add(CivAllxml,uid_civ2,'element',fieldnames{ilist}); |
---|
1905 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1906 | end |
---|
1907 | end |
---|
1908 | end |
---|
1909 | end |
---|
1910 | |
---|
1911 | % CheckFix2 |
---|
1912 | if Param.CheckFix2==1 |
---|
1913 | switch CivMode |
---|
1914 | case 'CivX' |
---|
1915 | cmd=[cmd... |
---|
1916 | cmd_fix(filecell.nc.civ2{ifile,j},Param,'Fix2') '\n']; |
---|
1917 | case 'CivAll' |
---|
1918 | fix2.inputFileName=filecell.nc.civ2{ifile,j} ; |
---|
1919 | fix2.fi1=num2str(flagindex2(1)); |
---|
1920 | fix2.fi2=num2str(flagindex2(2)); |
---|
1921 | fix2.fi3=num2str(flagindex2(3)); |
---|
1922 | fix2.threshC=num2str(thresh_vec2C); |
---|
1923 | fix2.threshV=num2str(thresh_vel2); |
---|
1924 | fieldnames=fields(fix2); |
---|
1925 | [CivAllxml,uid_fix2]=add(CivAllxml,1,'element','fix2'); |
---|
1926 | for ilist=1:length(fieldnames) |
---|
1927 | val=eval(['fix2.' fieldnames{ilist}]); |
---|
1928 | if ischar(val) |
---|
1929 | [CivAllxml,uid_t]=add(CivAllxml,uid_fix2,'element',fieldnames{ilist}); |
---|
1930 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1931 | end |
---|
1932 | end |
---|
1933 | CivAllCmd=[CivAllCmd ' fix2 ']; |
---|
1934 | end |
---|
1935 | end |
---|
1936 | |
---|
1937 | %CheckPatch2 |
---|
1938 | if Param.CheckPatch2==1 |
---|
1939 | switch CivMode |
---|
1940 | case 'CivX' |
---|
1941 | cmd=[cmd... |
---|
1942 | cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch2') '\n']; |
---|
1943 | case 'CivAll' |
---|
1944 | patch2.inputFileName=filecell.nc.civ1{ifile,j} ; |
---|
1945 | patch2.nopt=subdomain_patch2; |
---|
1946 | patch2.maxdiff=thresh_patch2; |
---|
1947 | patch2.ro=rho_patch2; |
---|
1948 | test_grid=get(handles.get_gridpatch2,'Value'); |
---|
1949 | if test_grid |
---|
1950 | patch2.gridflag='y'; |
---|
1951 | gridname=get(handles.grid_patch2,'String'); |
---|
1952 | if isequal(gridname(end-3:end),'grid') |
---|
1953 | nbslice_grid=str2double(gridname(1:end-4)); % |
---|
1954 | if ~isnan(nbslice_grid) |
---|
1955 | num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1; |
---|
1956 | patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')]; |
---|
1957 | if ~exist(patch2.gridPatch,'file') |
---|
1958 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
1959 | end |
---|
1960 | elseif exist(gridname,'file') |
---|
1961 | patch2.gridPatch=gridname; |
---|
1962 | else |
---|
1963 | msgbox_uvmat('ERROR','grid file absent for patch2') |
---|
1964 | end |
---|
1965 | end |
---|
1966 | else |
---|
1967 | patch2.gridPatch='none'; |
---|
1968 | patch2.gridflag='n'; |
---|
1969 | patch2.m=nx_patch2; |
---|
1970 | patch2.n=ny_patch2; |
---|
1971 | end |
---|
1972 | patch2.convectFlow='n'; |
---|
1973 | fieldnames=fields(patch2); |
---|
1974 | [CivAllxml,uid_patch2]=add(CivAllxml,1,'element','patch2'); |
---|
1975 | for ilist=1:length(fieldnames) |
---|
1976 | val=eval(['patch2.' fieldnames{ilist}]); |
---|
1977 | if ischar(val) |
---|
1978 | [CivAllxml,uid_t]=add(CivAllxml,uid_patch2,'element',fieldnames{ilist}); |
---|
1979 | [CivAllxml,uid_t2]=add(CivAllxml,uid_t,'chardata',val); |
---|
1980 | end |
---|
1981 | end |
---|
1982 | CivAllCmd=[CivAllCmd ' patch2 ']; |
---|
1983 | end |
---|
1984 | end |
---|
1985 | |
---|
1986 | switch CivMode |
---|
1987 | case {'CivX','CivAll'} |
---|
1988 | if isequal(CivMode,'CivAll') |
---|
1989 | save(CivAllxml,[OutputFile '.xml']); |
---|
1990 | cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml ' CivAllCmd ' >' OutputFile '.log' '\n']; |
---|
1991 | end |
---|
1992 | |
---|
1993 | % create the .bat file used in run or batch |
---|
1994 | filename_bat=[OutputFile '.bat']; |
---|
1995 | [fid,message]=fopen(filename_bat,'w'); |
---|
1996 | if isequal(fid,-1) |
---|
1997 | msgbox_uvmat('ERROR', ['creation of .bat file: ' message]) |
---|
1998 | return |
---|
1999 | end |
---|
2000 | fprintf(fid,cmd); |
---|
2001 | fclose(fid); |
---|
2002 | |
---|
2003 | if isunix |
---|
2004 | system(['chmod +x ' filename_bat]); |
---|
2005 | end |
---|
2006 | |
---|
2007 | batch_file_list{length(batch_file_list)+1}=filename_bat; |
---|
2008 | |
---|
2009 | % if batch |
---|
2010 | % switch batch_mode |
---|
2011 | % case 'sge' |
---|
2012 | % display(['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
2013 | % eval( ['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' filename_bat]); |
---|
2014 | % case 'oar' |
---|
2015 | % % eval( ['!chmod +x ' filename_bat]); |
---|
2016 | % % %eval( ['!oarsub -n CIVX -l /core=1,walltime=00:10:00 ' filename_bat]); |
---|
2017 | % % eval( ['!oarsub -n CIVX -l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:10:00" ' filename_bat]); |
---|
2018 | % |
---|
2019 | % cmd_str=['sh ' filename_bat]; |
---|
2020 | % super_cmd{length(super_cmd)+1}=cmd_str; |
---|
2021 | % |
---|
2022 | % end |
---|
2023 | % else |
---|
2024 | % %% to lauch the jobs locally : |
---|
2025 | % if(isunix) |
---|
2026 | % cmd_str=['. ' filename_bat]; |
---|
2027 | % else %case of Windows |
---|
2028 | % cmd_str=['@call "' regexprep(filename_bat,'\\','\\\\') '"']; |
---|
2029 | % end |
---|
2030 | % super_cmd=[super_cmd cmd_str '\n']; |
---|
2031 | % disp(cmd_str); |
---|
2032 | % end |
---|
2033 | case 'Matlab' |
---|
2034 | drawnow |
---|
2035 | if Param.CheckCiv1==1 |
---|
2036 | Param.Civ1=Param.Civ1; |
---|
2037 | end |
---|
2038 | if Param.CheckFix1==1 |
---|
2039 | fix1.WarnFlags=[]; |
---|
2040 | if get(handles.CheckFmin2,'Value') |
---|
2041 | fix1.WarnFlags=[fix1.WarnFlags -2]; |
---|
2042 | end |
---|
2043 | if get(handles.CheckF3,'Value') |
---|
2044 | fix1.WarnFlags=[fix1.WarnFlags 3]; |
---|
2045 | end |
---|
2046 | fix1.LowerBoundCorr=thresh_vecC1; |
---|
2047 | if get(handles.num_MinVel,'Value') |
---|
2048 | fix1.UppperBoundVel=thresh_vel1; |
---|
2049 | else |
---|
2050 | fix1.LowerBoundVel=thresh_vel1; |
---|
2051 | end |
---|
2052 | if get(handles.CheckMask,'Value') |
---|
2053 | fix1.MaskName=maskname; |
---|
2054 | end |
---|
2055 | Param.Fix1=fix1; |
---|
2056 | end |
---|
2057 | if Param.CheckPatch1==1 |
---|
2058 | if strcmp(compare,'stereo PIV') |
---|
2059 | filebase_A=filecell.filebase; |
---|
2060 | [pp,ff]=fileparts(filebase_A); |
---|
2061 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
2062 | RUN_STLIN(filecell.ncA.civ1{ifile,j},filecell.nc.civ1{ifile,j},'civ1',filecell.st{ifile,j},... |
---|
2063 | str2num(nx_patch1),str2num(ny_patch1),str2num(thresh_patch1),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
2064 | else |
---|
2065 | Param.Patch1.Rho=rho_patch1; |
---|
2066 | Param.Patch1.Threshold=thresh_patch1; |
---|
2067 | Param.Patch1.SubDomain=subdomain_patch1; |
---|
2068 | end |
---|
2069 | end |
---|
2070 | if Param.CheckCiv2==1 |
---|
2071 | Param.Civ2=Param.Civ2; |
---|
2072 | end |
---|
2073 | if Param.CheckFix2==1 |
---|
2074 | fix2.WarnFlags=[]; |
---|
2075 | if get(handles.CheckFmin2,'Value') |
---|
2076 | fix2.WarnFlags=[fix2.WarnFlags -2]; |
---|
2077 | end |
---|
2078 | if get(handles.CheckF4,'Value') |
---|
2079 | fix2.WarnFlags=[fix2.WarnFlags 4]; |
---|
2080 | end |
---|
2081 | if get(handles.CheckF3,'Value') |
---|
2082 | fix2.WarnFlags=[fix2.WarnFlags 3]; |
---|
2083 | end |
---|
2084 | fix2.LowerBoundCorr=thresh_vec2C; |
---|
2085 | if get(handles.num_MinVel,'Value') |
---|
2086 | fix2.UppperBoundVel=thresh_vel2; |
---|
2087 | else |
---|
2088 | fix2.LowerBoundVel=thresh_vel2; |
---|
2089 | end |
---|
2090 | if get(handles.CheckMask,'Value') |
---|
2091 | fix2.MaskName=maskname; |
---|
2092 | end |
---|
2093 | Param.Fix2=fix2; |
---|
2094 | end |
---|
2095 | if Param.CheckPatch2==1 |
---|
2096 | if strcmp(compare,'stereo PIV') |
---|
2097 | filebase_A=filecell.filebase; |
---|
2098 | [pp,ff]=fileparts(filebase_A); |
---|
2099 | filebase_B=fullfile(pp,get(handles.RootName_1,'String')); |
---|
2100 | RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},... |
---|
2101 | str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml']) |
---|
2102 | else |
---|
2103 | Param.Patch2.Rho=rho_patch2; |
---|
2104 | Param.Patch2.Threshold=thresh_patch2; |
---|
2105 | Param.Patch2.SubDomain=subdomain_patch2; |
---|
2106 | end |
---|
2107 | end |
---|
2108 | if ~strcmp(compare,'stereo PIV') |
---|
2109 | [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j}); |
---|
2110 | if isempty(errormsg) |
---|
2111 | display([filecell.nc.civ1{ifile,j} ' written']) |
---|
2112 | else |
---|
2113 | msgbox_uvmat('ERROR',errormsg) |
---|
2114 | end |
---|
2115 | |
---|
2116 | end |
---|
2117 | end |
---|
2118 | end |
---|
2119 | end |
---|
2120 | |
---|
2121 | if batch |
---|
2122 | switch batch_mode |
---|
2123 | case 'sge' |
---|
2124 | for p=1:length(batch_file_list) |
---|
2125 | cmd=['!qsub -p ' pvalue ' -q civ.q -e ' flname '.errors -o ' flname '.log' ' ' batch_file_list{p}]; |
---|
2126 | display(cmd);eval(cmd); |
---|
2127 | end |
---|
2128 | case 'oar_old' |
---|
2129 | for p=1:length(batch_file_list) |
---|
2130 | oar_command=['!oarsub -n CIVX -q nicejob '... |
---|
2131 | '-E ' regexprep(batch_file_list{p},'.bat','.errors') ' -O ' regexprep(batch_file_list{p},'.bat','.log ')... |
---|
2132 | '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; |
---|
2133 | display(oar_command);eval(oar_command); |
---|
2134 | end |
---|
2135 | case 'oar' %oar-dispatch.pl |
---|
2136 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
2137 | fid=fopen(filename_joblist,'w'); |
---|
2138 | |
---|
2139 | for p=1:length(batch_file_list) |
---|
2140 | oar_command=['oarsub -n CIVX '... |
---|
2141 | '-l "/core=1,walltime=00:10:00" ' batch_file_list{p}]; |
---|
2142 | fprintf(fid,[oar_command '\n']); |
---|
2143 | end |
---|
2144 | fclose(fid); |
---|
2145 | walltime=datestr(length(batch_file_list)*10/24/60,13); |
---|
2146 | oar_command=['oarsub -t container -n civx-container -l /core=24,walltime=' walltime ' "/fsnet/data/legi/calcul9/home/gostiaux/Documents/MATLAB/uvmat_dev/oar-dispatch -f '... |
---|
2147 | filename_joblist '"']; |
---|
2148 | filename_oarcommand=fullfile(Rootbat,'oar_command'); |
---|
2149 | fid=fopen(filename_oarcommand,'w'); |
---|
2150 | fprintf(fid,[oar_command '\n']); |
---|
2151 | fclose(fid); |
---|
2152 | display(oar_command); |
---|
2153 | eval(['! . ' filename_oarcommand]) |
---|
2154 | case 'oar_mpi' |
---|
2155 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
2156 | fid=fopen(filename_joblist,'w'); |
---|
2157 | |
---|
2158 | for p=1:length(batch_file_list) |
---|
2159 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
2160 | end |
---|
2161 | fclose(fid) |
---|
2162 | |
---|
2163 | |
---|
2164 | % oarsub -S ./oar.sub |
---|
2165 | |
---|
2166 | |
---|
2167 | |
---|
2168 | |
---|
2169 | |
---|
2170 | case 'oar_new' % to be develloped with Patrick Begou |
---|
2171 | filename_joblist=fullfile(Rootbat,'job_list.txt'); |
---|
2172 | fid=fopen(filename_superbat,'w'); |
---|
2173 | if fid==-1 |
---|
2174 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
2175 | return |
---|
2176 | end |
---|
2177 | for p=1:length(batch_file_list) |
---|
2178 | fprintf(fid,[batch_file_list{p} '\n']); |
---|
2179 | end |
---|
2180 | fclose(fid); |
---|
2181 | walltime=datestr(length(super_cmd)*10/24/60,13); |
---|
2182 | eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '" ' filename_superbat]); |
---|
2183 | end |
---|
2184 | else |
---|
2185 | if ~isequal(CivMode,'Matlab') |
---|
2186 | filename_superbat=fullfile(Rootbat,'job_list.bat'); |
---|
2187 | fid=fopen(filename_superbat,'w'); |
---|
2188 | if fid==-1 |
---|
2189 | msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) |
---|
2190 | return |
---|
2191 | end |
---|
2192 | for p=1:length(batch_file_list) |
---|
2193 | if isunix |
---|
2194 | fprintf(fid,['sh ' batch_file_list{p} '\n']); |
---|
2195 | else |
---|
2196 | fprintf(fid,['@call "' regexprep(filename_bat,'\\','\\\\') '"' '\n']); |
---|
2197 | end |
---|
2198 | end |
---|
2199 | fclose(fid); |
---|
2200 | if(isunix) |
---|
2201 | system(['chmod +x ' filename_superbat]); |
---|
2202 | end |
---|
2203 | system([filename_superbat ' &']);% execute main commmand |
---|
2204 | end |
---|
2205 | |
---|
2206 | end |
---|
2207 | |
---|
2208 | |
---|
2209 | %% save interface state |
---|
2210 | if isfield(filecell,'nc') |
---|
2211 | if isfield(filecell.nc,'civ2') |
---|
2212 | fileresu=filecell.nc.civ2{1,1}; |
---|
2213 | else |
---|
2214 | fileresu=filecell.nc.civ1{1,1}; |
---|
2215 | end |
---|
2216 | end |
---|
2217 | [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileresu); |
---|
2218 | namedoc=fullfile(RootPath,subdir,RootFile); |
---|
2219 | detect=1; |
---|
2220 | while detect==1 |
---|
2221 | namefigfull=[namedoc '.fig']; |
---|
2222 | hh=dir(namefigfull); |
---|
2223 | if ~isempty(hh) |
---|
2224 | detect=1; |
---|
2225 | namedoc=[namedoc '.0']; |
---|
2226 | else |
---|
2227 | detect=0; |
---|
2228 | end |
---|
2229 | end |
---|
2230 | saveas(gcbf,namefigfull);%save the interface with name namefigfull (A CHANGER EN FICHIER .xml) |
---|
2231 | |
---|
2232 | %Save info in personal profile (initiate browser next time) TODO |
---|
2233 | MenuFile={}; |
---|
2234 | dir_perso=prefdir; |
---|
2235 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2236 | if exist(profil_perso,'file') |
---|
2237 | hh=load (profil_perso); |
---|
2238 | if isfield(hh,'MenuFile') |
---|
2239 | MenuFile=hh.MenuFile; |
---|
2240 | end |
---|
2241 | if isfield(filecell.nc,'civ2') |
---|
2242 | MenuFile=[filecell.nc.civ2{1,1}; MenuFile]; |
---|
2243 | else |
---|
2244 | MenuFile=[filecell.nc.civ1{1,1}; MenuFile]; |
---|
2245 | end |
---|
2246 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
2247 | else |
---|
2248 | MenuFile=filecell.ima1.civ1(1,1); |
---|
2249 | save (profil_perso,'MenuFile') |
---|
2250 | end |
---|
2251 | |
---|
2252 | |
---|
2253 | %------------------------------------------------------------------------ |
---|
2254 | % --- determine the list of reference indices of processing file |
---|
2255 | function [ref_i,ref_j,errormsg]=find_ref_indices(handles) |
---|
2256 | %------------------------------------------------------------------------ |
---|
2257 | errormsg=''; %default error message |
---|
2258 | first_i=str2double(get(handles.first_i,'String'));%first index i |
---|
2259 | last_i=str2double(get(handles.last_i,'String'));%last index i |
---|
2260 | incr_i=str2double(get(handles.incr_i,'String'));% increment |
---|
2261 | if isequal(get(handles.first_j,'Visible'),'on') |
---|
2262 | first_j=str2double(get(handles.first_j,'String'));%first index j |
---|
2263 | last_j=str2double(get(handles.last_j,'String'));%last index j |
---|
2264 | incr_j=str2double(get(handles.incr_j,'String'));% increment |
---|
2265 | else |
---|
2266 | first_j=1; |
---|
2267 | last_j=1; |
---|
2268 | incr_j=1; |
---|
2269 | end |
---|
2270 | ref_i=first_i:incr_i:last_i;% list of i indices (reference values for each pair) |
---|
2271 | ref_j=first_j:incr_j:last_j;% list of j indices (reference values for each pair) |
---|
2272 | if isnan(first_i)||isnan(first_j) |
---|
2273 | errormsg='first field number not defined'; |
---|
2274 | elseif isnan(last_i)||isnan(last_j) |
---|
2275 | errormsg='last field number not defined'; |
---|
2276 | elseif isnan(incr_i)||isnan(incr_j) |
---|
2277 | errormsg='increment in field number not defined'; |
---|
2278 | elseif last_i < first_i || last_j < first_j |
---|
2279 | errormsg='last field number must be larger than the first one'; |
---|
2280 | end |
---|
2281 | |
---|
2282 | %------------------------------------------------------------------------ |
---|
2283 | % --- determine the list of filenames and indices needed for launch_job |
---|
2284 | function [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2,compare]=... |
---|
2285 | set_civ_filenames(handles,ref_i,ref_j,checkbox) |
---|
2286 | %------------------------------------------------------------------------ |
---|
2287 | filecell=[];%default |
---|
2288 | |
---|
2289 | %% get the root names nomenclature and numbers |
---|
2290 | filebase=get(handles.RootName,'String'); |
---|
2291 | |
---|
2292 | if isempty(filebase)||isequal(filebase,'') |
---|
2293 | msgbox_uvmat('ERROR','no input files') |
---|
2294 | return |
---|
2295 | end |
---|
2296 | |
---|
2297 | %filebase=regexprep(filebase,'\.fsnet','fsnet');% temporary fix for cluster Coriolis |
---|
2298 | filecell.filebase=filebase; |
---|
2299 | |
---|
2300 | browse=get(handles.RootName,'UserData'); |
---|
2301 | compare_list=get(handles.ListCompareMode,'String'); |
---|
2302 | val=get(handles.ListCompareMode,'Value'); |
---|
2303 | compare=compare_list{val}; |
---|
2304 | if strcmp(compare,'displacement') |
---|
2305 | mode='displacement'; |
---|
2306 | else |
---|
2307 | mode_list=get(handles.ListPairMode,'String'); |
---|
2308 | mode_value=get(handles.ListPairMode,'Value'); |
---|
2309 | mode=mode_list{mode_value}; |
---|
2310 | end |
---|
2311 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
2312 | ext_ima=get(handles.ImaExt,'String'); |
---|
2313 | nom_type_nc=browse.nom_type_nc; |
---|
2314 | if isfield(browse,'nom_type_ima') |
---|
2315 | nom_type_ima2=browse.nom_type_ima; |
---|
2316 | end |
---|
2317 | if isempty(nom_type_ima2),nom_type_ima2='1';end; %default |
---|
2318 | if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default |
---|
2319 | [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
2320 | find_pair_indices(handles,ref_i,ref_j,mode); |
---|
2321 | %determine the new filebase for 'displacement' ListPairMode (comparison of two series) |
---|
2322 | filebase_B=filebase;% root name of the second field series for stereo |
---|
2323 | if strcmp(compare,'displacement') || strcmp(compare,'stereo PIV') |
---|
2324 | % test_disp=1; |
---|
2325 | nom_type_ima1=browse.nom_type_ima_1; %nomenclature type of the second file series |
---|
2326 | [Path2,Name2]=fileparts(filebase_B); |
---|
2327 | Path1=Path2; |
---|
2328 | Name1=get(handles.RootName_1,'String');% root name of the first field series for stereo |
---|
2329 | filebase_A=fullfile(Path1,Name1); |
---|
2330 | if length(Name1)>6 |
---|
2331 | Name1=Name1(end-5:end); |
---|
2332 | end |
---|
2333 | if length(Name2)>6 |
---|
2334 | Name2=Name2(end-5:end); |
---|
2335 | end |
---|
2336 | filebase_AB=fullfile(Path2,[Name2 '-' Name1]); |
---|
2337 | else |
---|
2338 | % test_disp=0; |
---|
2339 | filebase_A=filebase; |
---|
2340 | nom_type_ima1=nom_type_ima2; |
---|
2341 | filebase_AB=filebase; |
---|
2342 | end |
---|
2343 | if strcmp(compare,'displacement') |
---|
2344 | filebase_ima1=filebase_A; |
---|
2345 | filebase_ima2=filebase_B; |
---|
2346 | filebase_nc=filebase_AB; %root name for the result of civ2 |
---|
2347 | else |
---|
2348 | filebase_ima1=filebase_B; |
---|
2349 | filebase_ima2=filebase_B; |
---|
2350 | filebase_nc=filebase_B; |
---|
2351 | end |
---|
2352 | |
---|
2353 | %determine reference files for fix: |
---|
2354 | file_ref_fix1={};%default |
---|
2355 | file_ref_fix2={}; |
---|
2356 | nbfield=length(num1_civ1); |
---|
2357 | nbslice=length(num_a_civ1); |
---|
2358 | if checkbox(2)==1% fix1 performed |
---|
2359 | ref=get(handles.ref_fix1,'UserData');%read data on the ref file stored by get_ref_fix1_Callback |
---|
2360 | if ~isempty(ref) |
---|
2361 | first_i=str2double(get(handles.first_i,'String')); |
---|
2362 | last_i=str2double(get(handles.last_i,'String')); |
---|
2363 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
2364 | first_j=str2double(get(handles.first_j,'String')); |
---|
2365 | last_j=str2double(get(handles.last_j,'String')); |
---|
2366 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
2367 | num_i_ref=first_i:incr_i:last_i; |
---|
2368 | num_j_ref=first_j:incr_j:last_j; |
---|
2369 | if isequal(mode,'displacement') |
---|
2370 | num_i1=num_i_ref; |
---|
2371 | num_i2=num_i_ref; |
---|
2372 | num_j1=num_j_ref; |
---|
2373 | num_j2=num_j_ref; |
---|
2374 | elseif isequal(mode,'pair j1-j2')% isequal(mode,'st_pair j1-j2') |
---|
2375 | num_i1=num_i_ref; |
---|
2376 | num_i2=num_i1; |
---|
2377 | num_j1=ref.num_a*ones(size(num_i_ref)); |
---|
2378 | num_j2=ref.num_b*ones(size(num_i_ref)); |
---|
2379 | elseif isequal(mode,'series(Di)') % isequal(mode,'st_series(Di)') |
---|
2380 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2381 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2382 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2383 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2384 | if isempty(ref.num_a) |
---|
2385 | ref.num_a=1; |
---|
2386 | end |
---|
2387 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2388 | num_j2=num_j1; |
---|
2389 | elseif isequal(mode,'series(Dj)')%| isequal(mode,'st_series(Dj)') |
---|
2390 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2391 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2392 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2393 | num_i2=num_i1; |
---|
2394 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2395 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2396 | end |
---|
2397 | for ifile=1:nbfield |
---|
2398 | for j=1:nbslice |
---|
2399 | 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);% |
---|
2400 | file_ref_fix1(ifile,j)={file_ref}; |
---|
2401 | if ~exist(file_ref,'file') |
---|
2402 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix1']) |
---|
2403 | filecell=[]; |
---|
2404 | return |
---|
2405 | end |
---|
2406 | end |
---|
2407 | end |
---|
2408 | end |
---|
2409 | end |
---|
2410 | |
---|
2411 | %determine reference files for checkfix2: |
---|
2412 | if checkbox(5)==1% fix2 performed |
---|
2413 | ref=get(handles.ref_fix2,'UserData'); |
---|
2414 | if ~isempty(ref) |
---|
2415 | first_i=str2double(get(handles.first_i,'String')); |
---|
2416 | last_i=str2double(get(handles.last_i,'String')); |
---|
2417 | incr_i=str2double(get(handles.incr_i,'String')); |
---|
2418 | first_j=str2double(get(handles.first_j,'String')); |
---|
2419 | last_j=str2double(get(handles.last_j,'String')); |
---|
2420 | incr_j=str2double(get(handles.incr_j,'String')); |
---|
2421 | num_i_ref=first_i:incr_i:last_i; |
---|
2422 | num_j_ref=first_j:incr_j:last_j; |
---|
2423 | if isequal(mode,'displacement') |
---|
2424 | num_i1=num_i_ref; |
---|
2425 | num_i2=num_i_ref; |
---|
2426 | num_j1=num_j_ref; |
---|
2427 | num_j2=num_j_ref; |
---|
2428 | elseif isequal(mode,'pair j1-j2') |
---|
2429 | num_i1=num_i_ref; |
---|
2430 | num_i2=num_i1; |
---|
2431 | num_j1=ref.num_a; |
---|
2432 | num_j2=ref.num_b; |
---|
2433 | elseif isequal(mode,'series(Di)') |
---|
2434 | delta1=floor((ref.num2-ref.num1)/2); |
---|
2435 | delta2=ceil((ref.num2-ref.num1)/2); |
---|
2436 | num_i1=num_i_ref-delta1*ones(size(num_i_ref)); |
---|
2437 | num_i2=num_i_ref+delta2*ones(size(num_i_ref)); |
---|
2438 | num_j1=ref.num_a*ones(size(num_i1)); |
---|
2439 | num_j2=num_j1; |
---|
2440 | elseif isequal(mode,'series(Dj)') |
---|
2441 | delta1=floor((ref.num_b-ref.num_a)/2); |
---|
2442 | delta2=ceil((ref.num_b-ref.num_a)/2); |
---|
2443 | num_i1=ref.num1*ones(size(num_i_ref)); |
---|
2444 | num_i2=num_i1; |
---|
2445 | num_j1=num_j_ref-delta1*ones(size(num_j_ref)); |
---|
2446 | num_j2=num_j_ref+delta2*ones(size(num_j_ref)); |
---|
2447 | end |
---|
2448 | for ifile=1:nbfield |
---|
2449 | for j=1:nbslice |
---|
2450 | 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);% |
---|
2451 | file_ref_fix2(ifile,j)={file_ref}; |
---|
2452 | if ~exist(file_ref,'file') |
---|
2453 | msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2']) |
---|
2454 | filecell={}; |
---|
2455 | return |
---|
2456 | end |
---|
2457 | end |
---|
2458 | end |
---|
2459 | end |
---|
2460 | end |
---|
2461 | |
---|
2462 | %check dir |
---|
2463 | subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data |
---|
2464 | subdir_civ2=get(handles.txt_SubdirCiv2,'String'); |
---|
2465 | if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir |
---|
2466 | if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir |
---|
2467 | % currentdir=pwd;%store the current working directory |
---|
2468 | [Path_ima,Name]=fileparts(filebase);%Path of the image files (.civ) |
---|
2469 | if ~exist(Path_ima,'dir') |
---|
2470 | msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found']) |
---|
2471 | filecell={}; |
---|
2472 | return |
---|
2473 | end |
---|
2474 | [xx,message]=fileattrib(Path_ima); |
---|
2475 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
2476 | msgbox_uvmat('ERROR',['No writting access to ' Path_ima]) |
---|
2477 | filecell={}; |
---|
2478 | % cd(currentdir); |
---|
2479 | return |
---|
2480 | end |
---|
2481 | |
---|
2482 | %check the existence of the netcdf and image files involved |
---|
2483 | % %%%%%%%%%%%% case CheckCiv1 activated %%%%%%%%%%%%% |
---|
2484 | if checkbox(1)==1; |
---|
2485 | detect=1; |
---|
2486 | vers=0; |
---|
2487 | subdir_civ1_new=subdir_civ1; |
---|
2488 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
2489 | for ifile=1:nbfield |
---|
2490 | for j=1:nbslice |
---|
2491 | 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); |
---|
2492 | detect=exist(filename,'file')==2; |
---|
2493 | if detect% if a netcdf file already exists |
---|
2494 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
2495 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
2496 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
2497 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
2498 | else |
---|
2499 | vers=vers+1; |
---|
2500 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)]; |
---|
2501 | end |
---|
2502 | subdir_civ2=subdir_civ1_new; |
---|
2503 | break |
---|
2504 | end |
---|
2505 | filecell.nc.civ1(ifile,j)={filename}; |
---|
2506 | end |
---|
2507 | if detect% if a netcdf file already exists |
---|
2508 | break |
---|
2509 | end |
---|
2510 | end |
---|
2511 | |
---|
2512 | %create the new txt_SubdirCiv1 |
---|
2513 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
2514 | % cd(Path_ima); |
---|
2515 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
2516 | |
---|
2517 | if ~strcmp(msg1,'') |
---|
2518 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1])%error message for directory creation |
---|
2519 | filecell={}; |
---|
2520 | return |
---|
2521 | elseif isunix |
---|
2522 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
2523 | if ~strcmp(msg2,'') |
---|
2524 | msgbox_uvmat('ERROR',['pb of permission for ' fullfile(Path_ima,subdir_civ1_new) ': ' msg2])%error message for directory creation |
---|
2525 | filecell={}; |
---|
2526 | return |
---|
2527 | end |
---|
2528 | end |
---|
2529 | % cd(currentdir); |
---|
2530 | end |
---|
2531 | if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series |
---|
2532 | for ifile=1:nbfield |
---|
2533 | for j=1:nbslice |
---|
2534 | 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);% |
---|
2535 | detect=exist(filename,'file')==2; |
---|
2536 | if detect% if a netcdf file already exists |
---|
2537 | indstr=regexp(subdir_civ1_new,'\D'); |
---|
2538 | if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number |
---|
2539 | vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1; |
---|
2540 | subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)]; |
---|
2541 | else |
---|
2542 | vers=vers+1; |
---|
2543 | subdir_civ1_new=[subdir_civ1_new '_' num2str(vers)]; |
---|
2544 | end |
---|
2545 | subdir_civ2=subdir_civ1; |
---|
2546 | break |
---|
2547 | end |
---|
2548 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
2549 | end |
---|
2550 | if detect% if a netcdf file already exists |
---|
2551 | break |
---|
2552 | end |
---|
2553 | end |
---|
2554 | %create the new txt_SubdirCiv1 |
---|
2555 | if ~exist(fullfile(Path_ima,subdir_civ1_new),'dir') |
---|
2556 | % cd(Path_ima); |
---|
2557 | [xx,msg1]=mkdir(fullfile(Path_ima,subdir_civ1_new)); |
---|
2558 | % cd(currentdir); |
---|
2559 | if ~strcmp(msg1,'') |
---|
2560 | msgbox_uvmat('ERROR',['cannot create ' subdir_civ1_new ': ' msg1]) |
---|
2561 | % cd(currentdir) |
---|
2562 | filecell={}; |
---|
2563 | return |
---|
2564 | else |
---|
2565 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ1_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
2566 | if ~strcmp(msg2,'') |
---|
2567 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_civ1_new ': ' msg2])%error message for directory creation |
---|
2568 | % cd(currentdir) |
---|
2569 | filecell={}; |
---|
2570 | return |
---|
2571 | end |
---|
2572 | end |
---|
2573 | end |
---|
2574 | end |
---|
2575 | end |
---|
2576 | subdir_civ1=subdir_civ1_new; |
---|
2577 | % get image names |
---|
2578 | for ifile=1:nbfield |
---|
2579 | for j=1:nbslice |
---|
2580 | filename=name_generator(filebase_ima1, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
2581 | idetect(j)=exist(filename,'file')==2; |
---|
2582 | filecell.ima1.civ1(ifile,j)={filename}; %first image |
---|
2583 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
2584 | idetect_1(j)=exist(filename,'file')==2; |
---|
2585 | filecell.ima2.civ1(ifile,j)={filename};%second image |
---|
2586 | end |
---|
2587 | [idetectmin,indexj]=min(idetect); |
---|
2588 | if idetectmin==0, |
---|
2589 | msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found']) |
---|
2590 | filecell={}; |
---|
2591 | % cd(currentdir) |
---|
2592 | return |
---|
2593 | end |
---|
2594 | [idetectmin,indexj]=min(idetect_1); |
---|
2595 | if idetectmin==0, |
---|
2596 | msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found']) |
---|
2597 | filecell={}; |
---|
2598 | %cd(currentdir) |
---|
2599 | return |
---|
2600 | end |
---|
2601 | end |
---|
2602 | if strcmp(compare,'stereo PIV') && (strcmp(mode,'pair j1-j2') || strcmp(mode,'series(Dj)') || strcmp(mode,'series(Di)')) |
---|
2603 | for ifile=1:nbfield |
---|
2604 | for j=1:nbslice |
---|
2605 | filename=name_generator(filebase_A, num1_civ1(ifile),num_a_civ1(j),ext_ima,nom_type_ima1); |
---|
2606 | idetect(j)=exist(filename,'file')==2; |
---|
2607 | filecell.imaA1.civ1(ifile,j)={filename} ;%first image |
---|
2608 | filename=name_generator(filebase_A, num2_civ1(ifile),num_b_civ1(j),ext_ima,nom_type_ima2); |
---|
2609 | idetect_1(j)=exist(filename,'file')==2; |
---|
2610 | filecell.imaA2.civ1(ifile,j)={filename};%second image |
---|
2611 | end |
---|
2612 | [idetectmin,indexj]=min(idetect); |
---|
2613 | if idetectmin==0, |
---|
2614 | msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found']) |
---|
2615 | filecell={}; |
---|
2616 | % cd(currentdir) |
---|
2617 | return |
---|
2618 | end |
---|
2619 | [idetectmin,indexj]=min(idetect_1); |
---|
2620 | if idetectmin==0, |
---|
2621 | msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found']) |
---|
2622 | filecell={}; |
---|
2623 | % cd(currentdir) |
---|
2624 | return |
---|
2625 | end |
---|
2626 | end |
---|
2627 | end |
---|
2628 | |
---|
2629 | %%%%%%%%%%%%% checkfix1 or checkpatch1 activated but no checkciv1 %%%%%%%%%%%%% |
---|
2630 | elseif (checkbox(2)==1 || checkbox(3)==1); |
---|
2631 | for ifile=1:nbfield |
---|
2632 | for j=1:nbslice |
---|
2633 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
2634 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
2635 | detect=exist(filename,'file')==2; |
---|
2636 | if detect==0 |
---|
2637 | msgbox_uvmat('ERROR',[filename ' not found']) |
---|
2638 | filecell={}; |
---|
2639 | % cd(currentdir) |
---|
2640 | return |
---|
2641 | end |
---|
2642 | filecell.nc.civ1(ifile,j)={filename}; |
---|
2643 | end |
---|
2644 | end |
---|
2645 | if strcmp(compare,'stereo PIV') |
---|
2646 | for ifile=1:nbfield |
---|
2647 | for j=1:nbslice |
---|
2648 | 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);% |
---|
2649 | filecell.ncA.civ1(ifile,j)={filename}; |
---|
2650 | if ~exist(filename,'file') |
---|
2651 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2652 | set(handles.RUN, 'Enable','On') |
---|
2653 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
2654 | filecell={}; |
---|
2655 | %cd(currentdir) |
---|
2656 | return |
---|
2657 | end |
---|
2658 | end |
---|
2659 | end |
---|
2660 | end |
---|
2661 | end |
---|
2662 | |
---|
2663 | %%%%%%%%%%%%% if checkciv2 performed with pairs different than checkciv1 %%%%%%%%%%%%% |
---|
2664 | testdiff=0; |
---|
2665 | if (checkbox(4)==1)&&... |
---|
2666 | ((get(handles.ListPairCiv1,'Value')~=get(handles.ListPairCiv2,'Value'))||~strcmp(subdir_civ2,subdir_civ1)) |
---|
2667 | testdiff=1; |
---|
2668 | detect=1; |
---|
2669 | vers=0; |
---|
2670 | subdir_civ2_new=subdir_civ2; |
---|
2671 | while detect==1 %create a new subdir if the netcdf files already exist |
---|
2672 | for ifile=1:nbfield |
---|
2673 | for j=1:nbslice |
---|
2674 | 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);% |
---|
2675 | detect=exist(filename,'file')==2; |
---|
2676 | if detect% if a netcdf file already exists |
---|
2677 | indstr=regexp(subdir_civ2,'\D'); |
---|
2678 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
2679 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
2680 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
2681 | else |
---|
2682 | vers=vers+1; |
---|
2683 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
2684 | end |
---|
2685 | break |
---|
2686 | end |
---|
2687 | filecell.nc.civ2(ifile,j)={filename}; |
---|
2688 | end |
---|
2689 | if detect% if a netcdf file already exists |
---|
2690 | break |
---|
2691 | end |
---|
2692 | end |
---|
2693 | %create the new subdir_civ2_new |
---|
2694 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
2695 | [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new)); |
---|
2696 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
2697 | if ~isequal(m2,'') |
---|
2698 | msgbox_uvmat('ERROR',['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2]) |
---|
2699 | filecell={}; |
---|
2700 | % cd(currentdir) |
---|
2701 | return |
---|
2702 | end |
---|
2703 | end |
---|
2704 | if strcmp(compare,'stereo PIV')%check second nc series |
---|
2705 | for ifile=1:nbfield |
---|
2706 | for j=1:nbslice |
---|
2707 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2708 | nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);% |
---|
2709 | detect=exist(filename,'file')==2; |
---|
2710 | if detect% if a netcdf file already exists |
---|
2711 | indstr=regexp(subdir_civ2,'\D'); |
---|
2712 | if indstr(end)<length(subdir_civ2) %subdir_civ1 ends by a number |
---|
2713 | vers=str2double(subdir_civ2(indstr(end)+1:end))+1; |
---|
2714 | subdir_civ2_new=[subdir_civ2(1:indstr(end)) num2str(vers)]; |
---|
2715 | else |
---|
2716 | vers=vers+1; |
---|
2717 | subdir_civ2_new=[subdir_civ1 '_' num2str(vers)]; |
---|
2718 | end |
---|
2719 | break |
---|
2720 | end |
---|
2721 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
2722 | end |
---|
2723 | if detect% if a netcdf file already exists |
---|
2724 | break |
---|
2725 | end |
---|
2726 | end |
---|
2727 | subdir_civ2=subdir_civ2_new; |
---|
2728 | %create the new txt_SubdirCiv1 |
---|
2729 | if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir') |
---|
2730 | [xx,m2]=mkdir(subdir_civ2_new); |
---|
2731 | [xx,msg2] = fileattrib(fullfile(Path_ima,subdir_civ2_new),'+w','g'); %yield writing access (+w) to user group (g) |
---|
2732 | if ~isequal(m2,'') |
---|
2733 | msgbox_uvmat('ERROR', ['cannot create ' fullfile(Path_ima,subdir_civ2_new) ': ' m2])%error message for directory creation |
---|
2734 | % cd(currentdir) |
---|
2735 | filecell={}; |
---|
2736 | return |
---|
2737 | end |
---|
2738 | end |
---|
2739 | end |
---|
2740 | end |
---|
2741 | subdir_civ2=subdir_civ2_new; |
---|
2742 | end |
---|
2743 | %cd(currentdir);%come back to the current working directory |
---|
2744 | |
---|
2745 | %%%%%%%%%%%%% if checkciv2 results are obtained or used %%%%%%%%%%%%% |
---|
2746 | if checkbox(4)==1 || checkbox(5)==1 || checkbox(6)==1 %civ2 |
---|
2747 | %check source netcdf file of checkciv1 estimates |
---|
2748 | if checkbox(1)==0; %no civ1 performed |
---|
2749 | for ifile=1:nbfield |
---|
2750 | for j=1:nbslice |
---|
2751 | filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
2752 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
2753 | filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file |
---|
2754 | if ~exist(filename,'file') |
---|
2755 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2756 | filecell={}; |
---|
2757 | return |
---|
2758 | end |
---|
2759 | if ~testdiff % civ2 or patch2 are written in the same file as civ1 |
---|
2760 | if checkbox(4)==0 ; %check the existence of civ2 if it is not calculated |
---|
2761 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
2762 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
2763 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2764 | filecell=[]; |
---|
2765 | return |
---|
2766 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
2767 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2768 | filecell=[]; |
---|
2769 | return |
---|
2770 | end |
---|
2771 | elseif checkbox(3)==0; %check the existence of patch if it is not calculated |
---|
2772 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch'); |
---|
2773 | if ~isempty(Data.CivStage) |
---|
2774 | if Data.CivStage<3 %test for civ files |
---|
2775 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
2776 | filecell=[]; |
---|
2777 | return |
---|
2778 | end |
---|
2779 | elseif isempty(Data.patch)||isequal(Data.patch,0) |
---|
2780 | msgbox_uvmat('ERROR',['no patch data in ' filename]) |
---|
2781 | filecell=[]; |
---|
2782 | return |
---|
2783 | end |
---|
2784 | end |
---|
2785 | end |
---|
2786 | end |
---|
2787 | end |
---|
2788 | if strcmp(compare,'stereo PIV') |
---|
2789 | for ifile=1:nbfield |
---|
2790 | for j=1:nbslice |
---|
2791 | filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2792 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
2793 | filecell.ncA.civ2(ifile,j)={filename}; |
---|
2794 | if ~exist(filename,'file') |
---|
2795 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2796 | set(handles.RUN, 'Enable','On') |
---|
2797 | set(handles.RUN,'BackgroundColor',[1 0 0]) |
---|
2798 | return |
---|
2799 | end |
---|
2800 | end |
---|
2801 | end |
---|
2802 | end |
---|
2803 | end |
---|
2804 | |
---|
2805 | detect=1; |
---|
2806 | % while detect==1%creates a new subdir if the netcdf files already contain checkciv2 data |
---|
2807 | for ifile=1:nbfield |
---|
2808 | for j=1:nbslice |
---|
2809 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2810 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2); |
---|
2811 | detect=exist(filename,'file')==2; |
---|
2812 | filecell.nc.civ2(ifile,j)={filename}; |
---|
2813 | end |
---|
2814 | end |
---|
2815 | %get first image names for checkciv2 |
---|
2816 | if checkbox(1)==1 && isequal(num1_civ1,num1_civ2) && isequal(num_a_civ1,num_a_civ2) |
---|
2817 | filecell.ima1.civ2=filecell.ima1.civ1; |
---|
2818 | elseif checkbox(4)==1 |
---|
2819 | for ifile=1:nbfield |
---|
2820 | for j=1:nbslice |
---|
2821 | filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1); |
---|
2822 | idetect_2(j)=exist(filename,'file')==2; |
---|
2823 | filecell.ima1.civ2(ifile,j)={filename};%first image |
---|
2824 | end |
---|
2825 | [idetectmin,indexj]=min(idetect_2); |
---|
2826 | if idetectmin==0, |
---|
2827 | msgbox_uvmat('ERROR',['input image ' filecell.ima1.civ2{ifile,indexj} ' not found']) |
---|
2828 | filecell=[]; |
---|
2829 | return |
---|
2830 | end |
---|
2831 | end |
---|
2832 | end |
---|
2833 | |
---|
2834 | %get second image names for checkciv2 |
---|
2835 | if checkbox(1)==1 && isequal(num2_civ1,num2_civ2) && isequal(num_b_civ1,num_b_civ2) |
---|
2836 | filecell.ima2.civ2=filecell.ima2.civ1; |
---|
2837 | elseif checkbox(4)==1 |
---|
2838 | for ifile=1:nbfield |
---|
2839 | for j=1:nbslice |
---|
2840 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2); |
---|
2841 | idetect_3(j)=exist(filename,'file')==2; |
---|
2842 | filecell.ima2.civ2(ifile,j)={filename};%first image |
---|
2843 | end |
---|
2844 | [idetectmin,indexj]=min(idetect_3); |
---|
2845 | if idetectmin==0, |
---|
2846 | msgbox_uvmat('ERROR',['input image ' filecell.ima2.civ2{ifile,indexj} ' not found']) |
---|
2847 | filecell=[]; |
---|
2848 | return |
---|
2849 | end |
---|
2850 | end |
---|
2851 | end |
---|
2852 | end |
---|
2853 | if (checkbox(5) || checkbox(6)) && ~checkbox(4) % need to read an existing netcdf civ2 file |
---|
2854 | if ~testdiff |
---|
2855 | filecell.nc.civ2=filecell.nc.civ1;% file already checked |
---|
2856 | else % check the civ2 files |
---|
2857 | for ifile=1:nbfield |
---|
2858 | for j=1:nbslice |
---|
2859 | filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2860 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
2861 | filecell.nc.civ2(ifile,j)={filename}; |
---|
2862 | if ~exist(filename,'file') |
---|
2863 | msgbox_uvmat('ERROR',['input file ' filename ' not found']) |
---|
2864 | filecell=[]; |
---|
2865 | return |
---|
2866 | else |
---|
2867 | Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2'); |
---|
2868 | if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files |
---|
2869 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2870 | filecell=[]; |
---|
2871 | return |
---|
2872 | elseif isempty(Data.civ2)||isequal(Data.civ2,0) |
---|
2873 | msgbox_uvmat('ERROR',['no civ2 data in ' filename]) |
---|
2874 | filecell=[]; |
---|
2875 | return |
---|
2876 | end |
---|
2877 | end |
---|
2878 | end |
---|
2879 | end |
---|
2880 | end |
---|
2881 | end |
---|
2882 | |
---|
2883 | %%%%%%%%%%%%% if stereo fields are calculated by PATCH %%%%%%%%%%%%% |
---|
2884 | if strcmp(compare,'stereo PIV') |
---|
2885 | if checkbox(3) && isequal(get(handles.test_stereo1,'Value'),1) |
---|
2886 | for ifile=1:nbfield |
---|
2887 | for j=1:nbslice |
---|
2888 | filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',... |
---|
2889 | nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);% |
---|
2890 | filecell.st(ifile,j)={filename}; |
---|
2891 | end |
---|
2892 | end |
---|
2893 | end |
---|
2894 | if checkbox(6) && isequal(get(handles.CheckStereo,'Value'),1) |
---|
2895 | for ifile=1:nbfield |
---|
2896 | for j=1:nbslice |
---|
2897 | filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',... |
---|
2898 | nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);% |
---|
2899 | filecell.st(ifile,j)={filename}; |
---|
2900 | end |
---|
2901 | end |
---|
2902 | end |
---|
2903 | end |
---|
2904 | set(handles.txt_SubdirCiv1,'String',subdir_civ1);%update the edit box |
---|
2905 | set(handles.txt_SubdirCiv2,'String',subdir_civ2);%update the edit box |
---|
2906 | browse.nom_type_nc=nom_type_nc; |
---|
2907 | set(handles.RootName,'UserData',browse); %update the nomenclature type for uvmat |
---|
2908 | |
---|
2909 | |
---|
2910 | %COPY IMAGES TO THE FORMAT .png IF NEEDED |
---|
2911 | if isequal(nom_type_ima1,'*')%case of movie files |
---|
2912 | nom_type_imanew1='_i'; |
---|
2913 | else |
---|
2914 | nom_type_imanew1=nom_type_ima1; |
---|
2915 | end |
---|
2916 | if isequal(nom_type_ima2,'*')%case of movie files |
---|
2917 | nom_type_imanew2='_i'; |
---|
2918 | else |
---|
2919 | nom_type_imanew2=nom_type_ima2; |
---|
2920 | end |
---|
2921 | if ~isequal(ext_ima,'.png') |
---|
2922 | %%type of image file |
---|
2923 | type_ima1='none';%default |
---|
2924 | movieobject1=[];%default |
---|
2925 | if strcmpi(ext_ima,'.avi') |
---|
2926 | hhh=which('mmreader'); |
---|
2927 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
2928 | type_ima1='movie'; |
---|
2929 | movieobject1=mmreader([filebase_ima2 ext_ima]); |
---|
2930 | else |
---|
2931 | type_ima1='avi'; |
---|
2932 | end |
---|
2933 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
2934 | form=imformats(ext_ima(2:end)); |
---|
2935 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
2936 | if isequal(nom_type_ima1,'*'); |
---|
2937 | type_ima1='multimage';%image series in a single image file |
---|
2938 | else |
---|
2939 | type_ima1='image'; |
---|
2940 | end |
---|
2941 | end |
---|
2942 | end |
---|
2943 | type_ima2='none';%default |
---|
2944 | movieobject2=[]; |
---|
2945 | if strcmpi(ext_ima,'.avi') |
---|
2946 | hhh=which('mmreader'); |
---|
2947 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab) |
---|
2948 | type_ima2='movie'; |
---|
2949 | movieobject2=mmreader([filebase_ima2 ext_ima]); |
---|
2950 | else |
---|
2951 | type_ima2='avi'; |
---|
2952 | end |
---|
2953 | elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) |
---|
2954 | form=imformats(ext_ima(2:end)); |
---|
2955 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
2956 | if isequal(nom_type_ima1,'*'); |
---|
2957 | type_ima2='multimage';%image series in a single image file |
---|
2958 | else |
---|
2959 | type_ima2='image'; |
---|
2960 | end |
---|
2961 | end |
---|
2962 | end |
---|
2963 | %npxy=get(handles.ImaExt,'UserData'); |
---|
2964 | % % if numel(npxy)<2 |
---|
2965 | % |
---|
2966 | % filename=name_generator(filebase_ima1,num1_civ1(1),num_a_civ1(1),ImaExt,nom_type_ima1); |
---|
2967 | % A=imread(filename); |
---|
2968 | % npxy=size(A); |
---|
2969 | % % end |
---|
2970 | % npy=npxy(1); |
---|
2971 | % npx=npxy(2); |
---|
2972 | if checkbox(1) %if civ1 is performed |
---|
2973 | h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar |
---|
2974 | for ifile=1:nbfield |
---|
2975 | waitbar(ifile/nbfield); |
---|
2976 | for j=1:nbslice |
---|
2977 | filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1); |
---|
2978 | if ~exist(filename,'file') |
---|
2979 | A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1); |
---|
2980 | imwrite(A,filename,'BitDepth',16); |
---|
2981 | end |
---|
2982 | filecell.ima1.civ1(ifile,j)={filename}; |
---|
2983 | filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2); |
---|
2984 | if ~exist(filename,'file') |
---|
2985 | A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2); |
---|
2986 | imwrite(A,filename,'BitDepth',16); |
---|
2987 | end |
---|
2988 | filecell.ima2.civ1(ifile,j)={filename}; |
---|
2989 | end |
---|
2990 | end |
---|
2991 | close(h) |
---|
2992 | end |
---|
2993 | if checkbox(4) %if civ2 is performed |
---|
2994 | h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar |
---|
2995 | for ifile=1:nbfield |
---|
2996 | waitbar(ifile/nbfield); |
---|
2997 | for j=1:nbslice |
---|
2998 | filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); |
---|
2999 | if ~exist(filename,'file') |
---|
3000 | A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); |
---|
3001 | imwrite(A,filename,'BitDepth',16); |
---|
3002 | end |
---|
3003 | filecell.ima1.civ2(ifile,j)={filename}; |
---|
3004 | filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); |
---|
3005 | if ~exist(filename,'file') |
---|
3006 | A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); |
---|
3007 | imwrite(A,filename,'BitDepth',16); |
---|
3008 | end |
---|
3009 | filecell.ima2.civ2(ifile,j)={filename}; |
---|
3010 | end |
---|
3011 | end |
---|
3012 | close(h); |
---|
3013 | end |
---|
3014 | end |
---|
3015 | |
---|
3016 | %------------------------------------------------------------------------ |
---|
3017 | % --- determine the list of index pairs of processing file |
---|
3018 | function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... |
---|
3019 | find_pair_indices(handles,ref_i,ref_j,mode) |
---|
3020 | %------------------------------------------------------------------------ |
---|
3021 | |
---|
3022 | list_civ1=get(handles.ListPairCiv1,'String'); |
---|
3023 | index_civ1=get(handles.ListPairCiv1,'Value'); |
---|
3024 | str_civ1=list_civ1{index_civ1};%string defining the image pairs for civ1 |
---|
3025 | if isempty(str_civ1)||isequal(str_civ1,'') |
---|
3026 | msgbox_uvmat('ERROR','no image pair selected for civ1') |
---|
3027 | return |
---|
3028 | end |
---|
3029 | list_civ2=get(handles.ListPairCiv2,'String'); |
---|
3030 | index_civ2=get(handles.ListPairCiv2,'Value'); |
---|
3031 | if index_civ2>length(list_civ2) |
---|
3032 | list_civ2=list_civ1; |
---|
3033 | index_civ2=index_civ1; |
---|
3034 | end |
---|
3035 | str_civ2=list_civ2{index_civ2};%string defining the image pairs for civ2 |
---|
3036 | |
---|
3037 | if isequal (mode,'series(Di)') |
---|
3038 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
3039 | num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers |
---|
3040 | num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); |
---|
3041 | num_a_civ1=ref_j; |
---|
3042 | num_b_civ1=ref_j; |
---|
3043 | num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); |
---|
3044 | num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); |
---|
3045 | num_a_civ2=ref_j; |
---|
3046 | num_b_civ2=ref_j; |
---|
3047 | |
---|
3048 | % adjust the first and last field number |
---|
3049 | lastfield=str2double(get(handles.nb_field,'String')); |
---|
3050 | if isnan(lastfield) |
---|
3051 | indsel=find((num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
3052 | else |
---|
3053 | indsel=find((num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1)); |
---|
3054 | end |
---|
3055 | if length(indsel)>=1 |
---|
3056 | firstind=indsel(1); |
---|
3057 | lastind=indsel(end); |
---|
3058 | set(handles.first_i,'String',num2str(ref_i(firstind)))%update the display of first and last fields |
---|
3059 | set(handles.last_i,'String',num2str(ref_i(lastind))) |
---|
3060 | ref_i=ref_i(indsel); |
---|
3061 | num1_civ1=num1_civ1(indsel); |
---|
3062 | num1_civ2=num1_civ2(indsel); |
---|
3063 | num2_civ1=num2_civ1(indsel); |
---|
3064 | num2_civ2=num2_civ2(indsel); |
---|
3065 | end |
---|
3066 | elseif isequal (mode,'series(Dj)') |
---|
3067 | lastfield_j=str2double(get(handles.nb_field2,'String')); |
---|
3068 | num1_civ1=ref_i;% set of first image numbers |
---|
3069 | num2_civ1=ref_i; |
---|
3070 | num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); |
---|
3071 | num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); |
---|
3072 | num1_civ2=ref_i; |
---|
3073 | num2_civ2=ref_i; |
---|
3074 | num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); |
---|
3075 | num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); |
---|
3076 | % adjust the first and last field number |
---|
3077 | if isnan(lastfield_j) |
---|
3078 | indsel=find((num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
3079 | else |
---|
3080 | indsel=find((num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1)); |
---|
3081 | end |
---|
3082 | if length(indsel)>=1 |
---|
3083 | firstind=indsel(1); |
---|
3084 | lastind=indsel(end); |
---|
3085 | set(handles.first_j,'String',num2str(ref_j(firstind)))%update the display of first and last fields |
---|
3086 | set(handles.last_j,'String',num2str(ref_j(lastind))) |
---|
3087 | ref_j=ref_j(indsel); |
---|
3088 | num_a_civ1=num_a_civ1(indsel); |
---|
3089 | num_b_civ1=num_b_civ1(indsel); |
---|
3090 | num_a_civ2=num_a_civ2(indsel); |
---|
3091 | num_b_civ2=num_b_civ2(indsel); |
---|
3092 | end |
---|
3093 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
3094 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
3095 | num1_civ1=ref_i; |
---|
3096 | num2_civ1=ref_i; |
---|
3097 | num_a_civ1=displ_num(1,index_civ1); |
---|
3098 | num_b_civ1=displ_num(2,index_civ1); |
---|
3099 | num1_civ2=ref_i; |
---|
3100 | num2_civ2=ref_i; |
---|
3101 | num_a_civ2=displ_num(1,index_civ2); |
---|
3102 | num_b_civ2=displ_num(2,index_civ2); |
---|
3103 | elseif isequal(mode,'displacement') |
---|
3104 | num1_civ1=ref_i; |
---|
3105 | num2_civ1=ref_i; |
---|
3106 | num_a_civ1=ref_j; |
---|
3107 | num_b_civ1=ref_j; |
---|
3108 | num1_civ2=ref_i; |
---|
3109 | num2_civ2=ref_i; |
---|
3110 | num_a_civ2=ref_j; |
---|
3111 | num_b_civ2=ref_j; |
---|
3112 | end |
---|
3113 | |
---|
3114 | |
---|
3115 | %------------------------------------------------------------------------ |
---|
3116 | % --- STEREO Interp |
---|
3117 | 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) |
---|
3118 | %------------------------------------------------------------------------ |
---|
3119 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
3120 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
3121 | ' -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 |
---|
3122 | |
---|
3123 | %------------------------------------------------------------------------ |
---|
3124 | % --- Executes on button press in CheckCiv1. |
---|
3125 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
3126 | %------------------------------------------------------------------------ |
---|
3127 | update_CivOptions(handles) |
---|
3128 | |
---|
3129 | %------------------------------------------------------------------------ |
---|
3130 | % --- Executes on button press in CheckFix1. |
---|
3131 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
3132 | %------------------------------------------------------------------------ |
---|
3133 | update_CivOptions(handles) |
---|
3134 | |
---|
3135 | %------------------------------------------------------------------------ |
---|
3136 | % --- Executes on button press in CheckPatch1. |
---|
3137 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
3138 | %------------------------------------------------------------------------ |
---|
3139 | update_CivOptions(handles) |
---|
3140 | |
---|
3141 | %------------------------------------------------------------------------ |
---|
3142 | % --- Executes on button press in CheckCiv2. |
---|
3143 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
3144 | %------------------------------------------------------------------------ |
---|
3145 | update_CivOptions(handles) |
---|
3146 | |
---|
3147 | %------------------------------------------------------------------------ |
---|
3148 | % --- Executes on button press in CheckFix2. |
---|
3149 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
3150 | %------------------------------------------------------------------------ |
---|
3151 | update_CivOptions(handles) |
---|
3152 | |
---|
3153 | %------------------------------------------------------------------------ |
---|
3154 | % --- Executes on button press in CheckPatch2. |
---|
3155 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
3156 | %------------------------------------------------------------------------ |
---|
3157 | update_CivOptions(handles) |
---|
3158 | |
---|
3159 | %------------------------------------------------------------------------ |
---|
3160 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
3161 | function update_CivOptions(handles) |
---|
3162 | %------------------------------------------------------------------------ |
---|
3163 | checkbox=zeros(1,6); |
---|
3164 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
3165 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
3166 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
3167 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
3168 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
3169 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
3170 | ind_selected=find(checkbox); |
---|
3171 | if ~isempty(ind_selected) |
---|
3172 | RootName=get(handles.RootName,'String'); |
---|
3173 | if isempty(RootName) |
---|
3174 | msgbox_uvmat('ERROR','No input file') |
---|
3175 | return |
---|
3176 | end |
---|
3177 | end |
---|
3178 | set(handles.PairIndices,'Visible','on') |
---|
3179 | set(handles.txt_SubdirCiv1,'Visible','on') |
---|
3180 | set(handles.ListSubdirCiv1,'Visible','on') |
---|
3181 | find_netcpair_civ1(handles) % select the available netcdf files |
---|
3182 | % check_civ2pair=ind_selected(4;6); |
---|
3183 | if max(checkbox(4:6))% case of civ2 pair choice needed |
---|
3184 | set(handles.TitlePairCiv2,'Visible','on') |
---|
3185 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
3186 | set(handles.txt_SubdirCiv2,'Visible','on') |
---|
3187 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
3188 | set(handles.ListPairCiv2,'Visible','on') |
---|
3189 | find_netcpair_civ2(handles) % select the available netcdf files |
---|
3190 | else |
---|
3191 | set(handles.TitleSubdirCiv2,'Visible','off') |
---|
3192 | set(handles.txt_SubdirCiv2,'Visible','off') |
---|
3193 | set(handles.ListSubdirCiv2,'Visible','off') |
---|
3194 | set(handles.ListPairCiv2,'Visible','off') |
---|
3195 | end |
---|
3196 | %index_last=find(checkbox,1,'last');%last selected button |
---|
3197 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
3198 | for ilist=1:length(options) |
---|
3199 | if checkbox(ilist) |
---|
3200 | set(handles.(options{ilist}),'Visible','on') |
---|
3201 | else |
---|
3202 | set(handles.(options{ilist}),'Visible','off') |
---|
3203 | end |
---|
3204 | end |
---|
3205 | |
---|
3206 | % end |
---|
3207 | |
---|
3208 | % set(handles.(operations(ind_selected)),'Visible','on') |
---|
3209 | % |
---|
3210 | % if state |
---|
3211 | % RootName=get(handles.RootName,'String'); |
---|
3212 | % if isempty(RootName) |
---|
3213 | % msgbox_uvmat('ERROR','No input file') |
---|
3214 | % return |
---|
3215 | % end |
---|
3216 | % set(handles.Civ1,'Visible','on') |
---|
3217 | % set(handles.PairIndices,'Visible','on') |
---|
3218 | % else |
---|
3219 | % set(handles.Civ1,'Visible','off') |
---|
3220 | % end |
---|
3221 | |
---|
3222 | |
---|
3223 | %------------------------------------------------------------------------ |
---|
3224 | function first_i_Callback(hObject, eventdata, handles) |
---|
3225 | %------------------------------------------------------------------------ |
---|
3226 | % last_i_Callback(hObject, eventdata, handles) |
---|
3227 | first_i=str2double(get(handles.first_i,'String')); |
---|
3228 | % last_i=str2num(get(handles.last_i,'String')); |
---|
3229 | % ref_i=ceil((first_i+last_i)/2); |
---|
3230 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
3231 | %set(handles.ref_i_civ2,'String', num2str(first_i))% reference index for pair dt = first index |
---|
3232 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3233 | |
---|
3234 | %------------------------------------------------------------------------ |
---|
3235 | function first_j_Callback(hObject, eventdata, handles) |
---|
3236 | %------------------------------------------------------------------------ |
---|
3237 | first_j=str2num(get(handles.first_j,'String')); |
---|
3238 | set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
3239 | ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
3240 | |
---|
3241 | %------------------------------------------------------------------------ |
---|
3242 | % --- Executes on button press in SearchRange: determine the search range num_Searchx,num_Searchy |
---|
3243 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
3244 | %------------------------------------------------------------------------ |
---|
3245 | %determine pair numbers |
---|
3246 | if strcmp(get(handles.umin,'Visible'),'off') |
---|
3247 | set(handles.u_title,'Visible','on') |
---|
3248 | set(handles.v_title,'Visible','on') |
---|
3249 | set(handles.umin,'Visible','on') |
---|
3250 | set(handles.umax,'Visible','on') |
---|
3251 | set(handles.vmin,'Visible','on') |
---|
3252 | set(handles.vmax,'Visible','on') |
---|
3253 | set(handles.CoordUnit,'Visible','on') |
---|
3254 | set(handles.TimeUnit,'Visible','on') |
---|
3255 | set(handles.slash_title,'Visible','on') |
---|
3256 | set(handles.min_title,'Visible','on') |
---|
3257 | set(handles.max_title,'Visible','on') |
---|
3258 | set(handles.unit_title,'Visible','on') |
---|
3259 | else |
---|
3260 | get_search_range(hObject, eventdata, handles) |
---|
3261 | end |
---|
3262 | |
---|
3263 | %------------------------------------------------------------------------ |
---|
3264 | % --- determine the search range num_Searchx,num_Searchy and shift |
---|
3265 | function get_search_range(hObject, eventdata, handles) |
---|
3266 | umin=str2double(get(handles.umin,'String')); |
---|
3267 | umax=str2double(get(handles.umax,'String')); |
---|
3268 | vmin=str2double(get(handles.umin,'String')); |
---|
3269 | vmax=str2double(get(handles.vmax,'String')); |
---|
3270 | %switch min_title and max_title in case of error |
---|
3271 | if umax<=umin |
---|
3272 | umin_old=umin; |
---|
3273 | umin=umax; |
---|
3274 | umax=umin_old; |
---|
3275 | set(handles.umin,'String', num2str(umin)) |
---|
3276 | set(handles.umax,'String', num2str(umax)) |
---|
3277 | end |
---|
3278 | if vmax<=vmin |
---|
3279 | vmin_old=vmin; |
---|
3280 | vmin=vmax; |
---|
3281 | vmax=vmin_old; |
---|
3282 | set(handles.vmin,'String', num2str(vmin)) |
---|
3283 | set(handles.vmax,'String', num2str(vmax)) |
---|
3284 | end |
---|
3285 | if ~(isnan(umin)||isnan(umax)||isnan(vmin)||isnan(vmax)) |
---|
3286 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
3287 | index=get(handles.ListPairCiv1,'Value'); |
---|
3288 | displ_num=get(handles.ListPairCiv1,'UserData'); |
---|
3289 | time=get(handles.ImaDoc,'UserData'); %get the set of times |
---|
3290 | pxcm_xy=get(handles.SearchRange,'UserData'); |
---|
3291 | pxcmx=pxcm_xy(1); |
---|
3292 | pxcmy=pxcm_xy(2); |
---|
3293 | mode_list=get(handles.ListPairMode,'String'); |
---|
3294 | mode_value=get(handles.ListPairMode,'Value'); |
---|
3295 | mode=mode_list{mode_value}; |
---|
3296 | if isequal (mode, 'series(Di)' ) |
---|
3297 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
3298 | num1=ref_i-floor(index/2);% first image numbers |
---|
3299 | num2=ref_i+ceil(index/2); |
---|
3300 | num_a=1; |
---|
3301 | num_b=1; |
---|
3302 | elseif isequal (mode, 'series(Dj)') |
---|
3303 | num1=1; |
---|
3304 | num2=1; |
---|
3305 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
3306 | num_a=ref_j-floor(index/2);% first image numbers |
---|
3307 | num_b=ref_j+ceil(index/2); |
---|
3308 | elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
3309 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
3310 | num1=ref_i; |
---|
3311 | num2=ref_i; |
---|
3312 | num_a=displ_num(1,index); |
---|
3313 | num_b=displ_num(2,index); |
---|
3314 | end |
---|
3315 | dt=time(num2,num_b)-time(num1,num_a); |
---|
3316 | ibx=str2double(get(handles.num_Bx,'String')); |
---|
3317 | iby=str2double(get(handles.num_By,'String')); |
---|
3318 | umin=dt*pxcmx*umin; |
---|
3319 | umax=dt*pxcmx*umax; |
---|
3320 | vmin=dt*pxcmy*vmin; |
---|
3321 | vmax=dt*pxcmy*vmax; |
---|
3322 | shiftx=round((umin+umax)/2); |
---|
3323 | shifty=round((vmin+vmax)/2); |
---|
3324 | isx=(umax+2-shiftx)*2+ibx; |
---|
3325 | isx=2*ceil(isx/2)+1; |
---|
3326 | isy=(vmax+2-shifty)*2+iby; |
---|
3327 | isy=2*ceil(isy/2)+1; |
---|
3328 | set(handles.num_Shiftx,'String',num2str(shiftx)); |
---|
3329 | set(handles.num_Shifty,'String',num2str(shifty)); |
---|
3330 | set(handles.num_Searchx,'String',num2str(isx)); |
---|
3331 | set(handles.num_Searchy,'String',num2str(isy)); |
---|
3332 | end |
---|
3333 | |
---|
3334 | %------------------------------------------------------------------------ |
---|
3335 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
3336 | function txt_SubdirCiv1_Callback(hObject, eventdata, handles) |
---|
3337 | %------------------------------------------------------------------------ |
---|
3338 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
3339 | set(handles.txt_SubdirCiv2,'String',subdir);% set civ2 directory the same as civ1 by default |
---|
3340 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
3341 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
3342 | if isempty(ichoice) |
---|
3343 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
3344 | else |
---|
3345 | ilist=ichoice; |
---|
3346 | end |
---|
3347 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
3348 | if get(handles.CheckCiv1,'Value')==0 |
---|
3349 | find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory |
---|
3350 | end |
---|
3351 | |
---|
3352 | %------------------------------------------------------------------------ |
---|
3353 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
3354 | function txt_SubdirCiv2_Callback(hObject, eventdata, handles) |
---|
3355 | %------------------------------------------------------------------------ |
---|
3356 | subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
3357 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
3358 | ichoice=find(strcmp(subdir,menu_str),1); |
---|
3359 | if isempty(ichoice) |
---|
3360 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
3361 | else |
---|
3362 | ilist=ichoice; |
---|
3363 | end |
---|
3364 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
3365 | %update the list of available pairs from netcdf files in the new directory |
---|
3366 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
3367 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
3368 | end |
---|
3369 | |
---|
3370 | % %------------------------------------------------------------------------ |
---|
3371 | % % --- Executes on button press in CheckMask: select box for mask option |
---|
3372 | % function check_Mask_Callback(hObject, eventdata, handles) |
---|
3373 | % %------------------------------------------------------------------------ |
---|
3374 | % maskval=get(handles.CheckMask,'Value'); |
---|
3375 | % if isequal(maskval,0) |
---|
3376 | % set(handles.txt_MaskName,'Visible','off') |
---|
3377 | % % set(handles.txt_MaskName,'String','') |
---|
3378 | % else |
---|
3379 | % mask_displ='no mask'; %default |
---|
3380 | % filebase=get(handles.RootName,'String'); |
---|
3381 | % [ nbslice_mask, flag_mask]=get_mask(filebase,handles); |
---|
3382 | % if isequal(flag_mask,1) |
---|
3383 | % mask_displ=[num2str(nbslice_mask) 'mask']; |
---|
3384 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3385 | % common_path=fileparts(filebase); |
---|
3386 | % filebase_a=fullfile(common_path,get(handles.RootName_1,'String')); |
---|
3387 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3388 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice_mask) |
---|
3389 | % mask_displ='no mask'; |
---|
3390 | % end |
---|
3391 | % end |
---|
3392 | % if isequal(mask_displ,'no mask') |
---|
3393 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
3394 | % {'*.png', ' (*.png)'; |
---|
3395 | % '*.png', '.png files '; ... |
---|
3396 | % '*.*', 'All Files (*.*)'}, ... |
---|
3397 | % 'Pick a mask file *.png',filebase); |
---|
3398 | % mask_displ=fullfile(PathName,FileName); |
---|
3399 | % if exist(mask_displ,'file') |
---|
3400 | % set(handles.txt_MaskName,'Visible','on') |
---|
3401 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
3402 | % % mask_displ='no mask'; |
---|
3403 | % end |
---|
3404 | % end |
---|
3405 | % if isequal(mask_displ,'no mask') |
---|
3406 | % set(handles.CheckMask,'Value',0) |
---|
3407 | % set(handles.CheckMask,'Value',0) |
---|
3408 | % set(handles.CheckMask,'Value',0) |
---|
3409 | % set(handles.CheckMask,'Value',0) |
---|
3410 | % else |
---|
3411 | % set(handles.CheckMask,'Value',1) |
---|
3412 | % set(handles.CheckMask,'Value',1) |
---|
3413 | % end |
---|
3414 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
3415 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
3416 | % set(handles.txt_Mask,'String',mask_displ) |
---|
3417 | % set(handles.txt_MaskName,'String',mask_displ) |
---|
3418 | % end |
---|
3419 | % set(handles.CheckMask,'Value',maskval)%update the checkciv2 mask with the same option as checkciv1 |
---|
3420 | |
---|
3421 | %------------------------------------------------------------------------ |
---|
3422 | % --- Executes on button press in CheckMask. |
---|
3423 | function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
3424 | %------------------------------------------------------------------------ |
---|
3425 | maskval=get(handles.CheckMask,'Value'); |
---|
3426 | if isequal(maskval,0) |
---|
3427 | set(handles.txt_MaskName,'String','') |
---|
3428 | else |
---|
3429 | mask_displ='no mask'; %default |
---|
3430 | filebase=get(handles.RootName,'String'); |
---|
3431 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
3432 | if isequal(flag_mask,1) |
---|
3433 | mask_displ=[num2str(nbslice) 'mask']; |
---|
3434 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3435 | filebase_a=get(handles.RootName_1,'String'); |
---|
3436 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3437 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
3438 | mask_displ='no mask'; |
---|
3439 | end |
---|
3440 | end |
---|
3441 | if isequal(mask_displ,'no mask') |
---|
3442 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3443 | {'*.png', ' (*.png)'; |
---|
3444 | '*.png', '.png files '; ... |
---|
3445 | '*.*', 'All Files (*.*)'}, ... |
---|
3446 | 'Pick a mask file *.png',filebase); |
---|
3447 | mask_displ=fullfile(PathName,FileName); |
---|
3448 | if ~exist(mask_displ,'file') |
---|
3449 | mask_displ='no mask'; |
---|
3450 | end |
---|
3451 | end |
---|
3452 | if isequal(mask_displ,'no mask') |
---|
3453 | set(handles.CheckMask,'Value',0) |
---|
3454 | set(handles.CheckMask,'Value',0) |
---|
3455 | set(handles.CheckMask,'Value',0) |
---|
3456 | else |
---|
3457 | %set(handles.CheckMask,'Value',1) |
---|
3458 | set(handles.CheckMask,'Value',1) |
---|
3459 | end |
---|
3460 | set(handles.txt_MaskName,'String',mask_displ) |
---|
3461 | set(handles.txt_Mask,'String',mask_displ) |
---|
3462 | set(handles.txt_MaskName,'String',mask_displ) |
---|
3463 | end |
---|
3464 | |
---|
3465 | %------------------------------------------------------------------------ |
---|
3466 | % --- Executes on button press in CheckMask: select box for mask option |
---|
3467 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
3468 | %------------------------------------------------------------------------ |
---|
3469 | maskval=get(handles.CheckMask,'Value'); |
---|
3470 | if isequal(maskval,0) |
---|
3471 | set(handles.txt_Mask,'String','') |
---|
3472 | else |
---|
3473 | mask_displ='no mask'; %default |
---|
3474 | filebase=get(handles.RootName,'String'); |
---|
3475 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
3476 | if isequal(flag_mask,1) |
---|
3477 | mask_displ=[num2str(nbslice) 'mask']; |
---|
3478 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3479 | filebase_a=get(handles.RootName_1,'String'); |
---|
3480 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3481 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
3482 | mask_displ='no mask'; |
---|
3483 | end |
---|
3484 | end |
---|
3485 | if isequal(mask_displ,'no mask') |
---|
3486 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3487 | {'*.png', ' (*.png)'; |
---|
3488 | '*.png', '.png files '; ... |
---|
3489 | '*.*', 'All Files (*.*)'}, ... |
---|
3490 | 'Pick a mask file *.png',filebase); |
---|
3491 | mask_displ=fullfile(PathName,FileName); |
---|
3492 | if ~exist(mask_displ,'file') |
---|
3493 | mask_displ='no mask'; |
---|
3494 | end |
---|
3495 | end |
---|
3496 | if isequal(mask_displ,'no mask') |
---|
3497 | set(handles.CheckMask,'Value',0) |
---|
3498 | set(handles.CheckMask,'Value',0) |
---|
3499 | else |
---|
3500 | set(handles.CheckMask,'Value',1) |
---|
3501 | end |
---|
3502 | set(handles.txt_Mask,'String',mask_displ) |
---|
3503 | set(handles.txt_MaskName,'String',mask_displ) |
---|
3504 | end |
---|
3505 | |
---|
3506 | %------------------------------------------------------------------------ |
---|
3507 | % --- Executes on button press in CheckMask. |
---|
3508 | function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
3509 | %------------------------------------------------------------------------ |
---|
3510 | maskval=get(handles.CheckMask,'Value'); |
---|
3511 | if isequal(maskval,0) |
---|
3512 | set(handles.txt_MaskName,'String','') |
---|
3513 | else |
---|
3514 | mask_displ='no mask'; %default |
---|
3515 | filebase=get(handles.RootName,'String'); |
---|
3516 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
3517 | if isequal(flag_mask,1) |
---|
3518 | mask_displ=[num2str(nbslice) 'mask']; |
---|
3519 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
3520 | filebase_a=get(handles.RootName_1,'String'); |
---|
3521 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
3522 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
3523 | mask_displ='no mask'; |
---|
3524 | end |
---|
3525 | end |
---|
3526 | if isequal(mask_displ,'no mask') |
---|
3527 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3528 | {'*.png', ' (*.png)'; |
---|
3529 | '*.png', '.png files '; ... |
---|
3530 | '*.*', 'All Files (*.*)'}, ... |
---|
3531 | 'Pick a mask file *.png',filebase); |
---|
3532 | mask_displ=fullfile(PathName,FileName); |
---|
3533 | if ~exist(mask_displ,'file') |
---|
3534 | mask_displ='no mask'; |
---|
3535 | end |
---|
3536 | end |
---|
3537 | if isequal(mask_displ,'no mask') |
---|
3538 | set(handles.CheckMask,'Value',0) |
---|
3539 | end |
---|
3540 | set(handles.txt_MaskName,'String',mask_displ) |
---|
3541 | end |
---|
3542 | |
---|
3543 | %------------------------------------------------------------------------ |
---|
3544 | % --- function called to look for mask files |
---|
3545 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
3546 | %------------------------------------------------------------------------ |
---|
3547 | %detect mask files, images with appropriate file base |
---|
3548 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
3549 | %flag_mask=1 indicates detection |
---|
3550 | |
---|
3551 | flag_mask=0;%default |
---|
3552 | nbslice=1; |
---|
3553 | |
---|
3554 | % subdir=get(handles.txt_SubdirCiv1,'String'); |
---|
3555 | [Path,Name]=fileparts(filebase); |
---|
3556 | if ~isdir(Path) |
---|
3557 | msgbox_uvmat('ERROR','no path for input files') |
---|
3558 | return |
---|
3559 | end |
---|
3560 | % currentdir=pwd; |
---|
3561 | % cd(Path);%move in the dir of the root name filebase |
---|
3562 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
3563 | % cd(currentdir);%come back to the current working directory |
---|
3564 | if ~isempty(maskfiles) |
---|
3565 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
3566 | % else |
---|
3567 | flag_mask=1; |
---|
3568 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
3569 | [Path2,Name,ext]=fileparts(maskname); |
---|
3570 | Namedouble=double(Name); |
---|
3571 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
3572 | ind_mask=findstr('mask',Name); |
---|
3573 | i=ind_mask-1; |
---|
3574 | while val(i)==0 && i>0 |
---|
3575 | i=i-1; |
---|
3576 | end |
---|
3577 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
3578 | if ~isnan(nbslice) && Name(i)=='_' |
---|
3579 | flag_mask=1; |
---|
3580 | else |
---|
3581 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
3582 | return |
---|
3583 | nbslice=1; |
---|
3584 | end |
---|
3585 | end |
---|
3586 | |
---|
3587 | %------------------------------------------------------------------------ |
---|
3588 | % --- function called to look for grid files |
---|
3589 | function [nbslice, flag_mask]=get_grid(filebase,handles) |
---|
3590 | %------------------------------------------------------------------------ |
---|
3591 | flag_mask=0;%default |
---|
3592 | nbslice=1; |
---|
3593 | [Path,Name]=fileparts(filebase); |
---|
3594 | currentdir=pwd; |
---|
3595 | cd(Path);%move in the dir of the root name filebase |
---|
3596 | maskfiles=dir([Name '_*grid_*.grid']);%look for mask files |
---|
3597 | cd(currentdir);%come back to the current working directory |
---|
3598 | if ~isempty(maskfiles) |
---|
3599 | flag_mask=1; |
---|
3600 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
3601 | [Path2,Name,ext]=fileparts(maskname); |
---|
3602 | Namedouble=double(Name); |
---|
3603 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
3604 | ind_mask=findstr('grid',Name); |
---|
3605 | i=ind_mask-1; |
---|
3606 | while val(i)==0 && i>0 |
---|
3607 | i=i-1; |
---|
3608 | end |
---|
3609 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
3610 | if ~isnan(nbslice) && Name(i)=='_' |
---|
3611 | flag_mask=1; |
---|
3612 | else |
---|
3613 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
3614 | return |
---|
3615 | nbslice=1; |
---|
3616 | end |
---|
3617 | end |
---|
3618 | |
---|
3619 | %------------------------------------------------------------------------ |
---|
3620 | % --- transform numbers to letters |
---|
3621 | function str=num2stra(num,nom_type) |
---|
3622 | %------------------------------------------------------------------------ |
---|
3623 | if isempty(nom_type) |
---|
3624 | str=''; |
---|
3625 | elseif strcmp(nom_type(end),'a') |
---|
3626 | str=char(96+num); |
---|
3627 | elseif strcmp(nom_type(end),'A') |
---|
3628 | str=char(96+num); |
---|
3629 | elseif isempty(nom_type(2:end))%a single index |
---|
3630 | str=''; |
---|
3631 | else |
---|
3632 | str=num2str(num); |
---|
3633 | end |
---|
3634 | |
---|
3635 | %------------------------------------------------------------------------ |
---|
3636 | % --- Executes on button press in ListSubdirCiv1. |
---|
3637 | function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
3638 | %------------------------------------------------------------------------ |
---|
3639 | list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
3640 | val=get(handles.ListSubdirCiv1,'Value'); |
---|
3641 | subdir=list_subdir_civ1{val}; |
---|
3642 | if strcmp(subdir,'new...') |
---|
3643 | subdir='CIV'; %default subdirectory |
---|
3644 | end |
---|
3645 | set(handles.txt_SubdirCiv1,'String',subdir); |
---|
3646 | find_netcpair_civ1(hObject, eventdata, handles) |
---|
3647 | % end |
---|
3648 | |
---|
3649 | %------------------------------------------------------------------------ |
---|
3650 | % --- Executes on button press in ListSubdirCiv2. |
---|
3651 | function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
3652 | %------------------------------------------------------------------------ |
---|
3653 | list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
3654 | val=get(handles.ListSubdirCiv2,'Value'); |
---|
3655 | subdir=list_subdir_civ2{val}; |
---|
3656 | if strcmp(subdir,'new...') |
---|
3657 | subdir='CIV'; %default subdirectory |
---|
3658 | end |
---|
3659 | set(handles.txt_SubdirCiv2,'String',subdir); |
---|
3660 | % set(handles.ListSubdirCiv2,'Value',1); |
---|
3661 | |
---|
3662 | |
---|
3663 | %------------------------------------------------------------------------ |
---|
3664 | % --- Executes on button press in CheckGrid. |
---|
3665 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
3666 | %------------------------------------------------------------------------ |
---|
3667 | value=get(hObject,'Value'); |
---|
3668 | hparent=get(hObject,'parent'); |
---|
3669 | hchildren=get(hparent,'children'); |
---|
3670 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
3671 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
3672 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
3673 | testgrid=0; |
---|
3674 | filegrid=''; |
---|
3675 | if value |
---|
3676 | filebase=get(handles.RootName,'String'); |
---|
3677 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
3678 | if isequal(flag_grid,1) |
---|
3679 | filegrid=[num2str(nbslice) 'grid']; |
---|
3680 | testgrid=1; |
---|
3681 | else % browse for a grid |
---|
3682 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
3683 | if exist(filegrid,'file') |
---|
3684 | filebase=filegrid; |
---|
3685 | end |
---|
3686 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3687 | {'*.grid', ' (*.grid)'; |
---|
3688 | '*.grid', '.grid files '; ... |
---|
3689 | '*.*', 'All Files (*.*)'}, ... |
---|
3690 | 'Pick a file',filebase); |
---|
3691 | filegrid=fullfile(PathName,FileName); |
---|
3692 | set(hObject,'UserData',filegrid);%store for future use |
---|
3693 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file')) |
---|
3694 | testgrid=1; |
---|
3695 | end |
---|
3696 | end |
---|
3697 | end |
---|
3698 | if testgrid |
---|
3699 | set(handle_dx,'Visible','off'); |
---|
3700 | set(handle_dy,'Visible','off'); |
---|
3701 | set(handle_txtbox,'Visible','on') |
---|
3702 | set(handle_txtbox,'String',filegrid) |
---|
3703 | else |
---|
3704 | set(hObject,'Value',0); |
---|
3705 | set(handle_dx,'Visible','on'); |
---|
3706 | set(handle_dy,'Visible','on'); |
---|
3707 | set(handle_txtbox,'Visible','off') |
---|
3708 | end |
---|
3709 | |
---|
3710 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
3711 | PanelName=get(hparent,'tag'); |
---|
3712 | if strcmp(PanelName,'panel_Civ1') |
---|
3713 | hchildren=get(handles.Civ2,'children'); |
---|
3714 | handle_checkbox=findobj(hchildren,'tag','check_Grid'); |
---|
3715 | handle_txtbox=findobj(hchildren,'tag','txt_GridName'); |
---|
3716 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
3717 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
3718 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
3719 | if testgrid |
---|
3720 | set(handle_checkbox,'Value',1); |
---|
3721 | set(handle_dx,'Visible','off'); |
---|
3722 | set(handle_dy,'Visible','off'); |
---|
3723 | set(handle_txtbox,'Visible','on') |
---|
3724 | set(handle_txtbox,'String',filegrid) |
---|
3725 | else |
---|
3726 | set(handle_checkbox,'Value',0); |
---|
3727 | set(handles.CheckGrid,'Value',0); |
---|
3728 | set(handle_dx,'Visible','on'); |
---|
3729 | set(handle_dy,'Visible','on'); |
---|
3730 | set(handle_txtbox,'Visible','off') |
---|
3731 | end |
---|
3732 | end |
---|
3733 | %------------------------------------------------------------------------ |
---|
3734 | % --- Executes on button press in CheckMask. |
---|
3735 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
3736 | %------------------------------------------------------------------------ |
---|
3737 | value=get(hObject,'Value'); |
---|
3738 | testmask=0; |
---|
3739 | if value |
---|
3740 | filebase=get(handles.RootName,'String'); |
---|
3741 | [nbslice, flag_mask]=get_mask(filebase,handles);% look for a mask with appropriate name |
---|
3742 | if isequal(flag_mask,1) |
---|
3743 | filemask=[num2str(nbslice) 'mask']; |
---|
3744 | testmask=1; |
---|
3745 | else % browse for a mask |
---|
3746 | filemask=get(handles.CheckMask,'UserData');%look for previous mask name stored as UserData |
---|
3747 | if exist(filemask,'file') |
---|
3748 | filebase=filemask; |
---|
3749 | end |
---|
3750 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3751 | {'*.png', ' (*.png)'; |
---|
3752 | '*.png', '.png files '; ... |
---|
3753 | '*.*', 'All Files (*.*)'}, ... |
---|
3754 | 'Pick a mask file *.png',filebase); |
---|
3755 | filemask=fullfile(PathName,FileName); |
---|
3756 | set(handles.CheckMask,'UserData',filemask);%store for future use |
---|
3757 | if ~(isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filemask,'file')) |
---|
3758 | testmask=1; |
---|
3759 | end |
---|
3760 | end |
---|
3761 | end |
---|
3762 | if testmask |
---|
3763 | set(handles.num_Dx,'Visible','off'); |
---|
3764 | set(handles.num_Dy,'Visible','off'); |
---|
3765 | set(handles.num_Dx,'Visible','off'); |
---|
3766 | set(handles.num_Dy,'Visible','off'); |
---|
3767 | set(handles.txt_MaskName,'Visible','on') |
---|
3768 | set(handles.txt_MaskName,'String',filemask) |
---|
3769 | else |
---|
3770 | set(handles.CheckMask,'Value',0); |
---|
3771 | set(handles.CheckGrid,'Value',0); |
---|
3772 | set(handles.num_Dx,'Visible','on'); |
---|
3773 | set(handles.num_Dy,'Visible','on'); |
---|
3774 | set(handles.num_Dx,'Visible','on'); |
---|
3775 | set(handles.num_Dy,'Visible','on'); |
---|
3776 | set(handles.txt_MaskName,'Visible','off') |
---|
3777 | end |
---|
3778 | |
---|
3779 | %------------------------------------------------------------------------ |
---|
3780 | % --- Executes on button press in CheckGrid. |
---|
3781 | function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
3782 | %------------------------------------------------------------------------ |
---|
3783 | value=get(handles.CheckGrid,'Value'); |
---|
3784 | if value |
---|
3785 | filebase=get(handles.RootName,'String'); |
---|
3786 | [nbslice, flag_grid]=get_grid(filebase,handles); |
---|
3787 | if isequal(flag_grid,1) |
---|
3788 | mask_displ=[num2str(nbslice) 'grid']; |
---|
3789 | set(handles.txt_GridName,'String',mask_displ) |
---|
3790 | set(handles.num_Dx,'Visible','off'); |
---|
3791 | set(handles.num_Dy,'Visible','off'); |
---|
3792 | else |
---|
3793 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3794 | {'*.grid', ' (*.grid)'; |
---|
3795 | '*.grid', '.grid files '; ... |
---|
3796 | '*.*', 'All Files (*.*)'}, ... |
---|
3797 | 'Pick a file',filebase); |
---|
3798 | filegrid=fullfile(PathName,FileName); |
---|
3799 | if isempty(FileName)||isempty(PathName)||isequal(FileName,0)||~exist(filegrid,'file') |
---|
3800 | set(handles.CheckGrid,'Value',0); |
---|
3801 | set(handles.txt_GridName,'string',''); |
---|
3802 | set(handles.num_Dx,'Visible','on'); |
---|
3803 | set(handles.num_Dy,'Visible','on'); |
---|
3804 | set(handles.txt_GridName,'string',''); |
---|
3805 | else |
---|
3806 | set(handles.txt_GridName,'string',filegrid); |
---|
3807 | set(handles.num_Dx,'Visible','off'); |
---|
3808 | set(handles.num_Dy,'Visible','off'); |
---|
3809 | set(handles.txt_GridName,'string',filegrid); |
---|
3810 | end |
---|
3811 | end |
---|
3812 | else |
---|
3813 | set(handles.txt_GridName,'string',''); |
---|
3814 | set(handles.num_Dx,'Visible','on'); |
---|
3815 | set(handles.num_Dy,'Visible','on'); |
---|
3816 | set(handles.txt_GridName,'string',''); |
---|
3817 | end |
---|
3818 | |
---|
3819 | % % --- Executes on button press in CheckGrid. |
---|
3820 | % function browse_gridciv2_Callback(hObject, eventdata, handles) |
---|
3821 | % |
---|
3822 | % filebase=get(handles.RootName,'String'); |
---|
3823 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
3824 | % {'*.grid', ' (*.grid)'; |
---|
3825 | % '*.grid', '.grid files '; ... |
---|
3826 | % '*.*', 'All Files (*.*)'}, ... |
---|
3827 | % 'Pick a file',filebase); |
---|
3828 | % filegrid=fullfile(PathName,FileName); |
---|
3829 | % set(handles.txt_GridName,'string',filegrid); |
---|
3830 | % set(handles.num_Dx,'String',' '); |
---|
3831 | % set(handles.num_Dy,'String',' '); |
---|
3832 | % % set(handles.grid_patch2,'string',filegrid); |
---|
3833 | |
---|
3834 | % --- Executes on button press in get_gridpatch1. |
---|
3835 | function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
3836 | % hObject handle to get_gridpatch1 (see GCBO) |
---|
3837 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
3838 | % handles structure with handles and user data (see GUIDATA) |
---|
3839 | |
---|
3840 | filebase=get(handles.RootName,'String'); |
---|
3841 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
3842 | {'*.grid', ' (*.grid)'; |
---|
3843 | '*.grid', '.grid files '; ... |
---|
3844 | '*.*', 'All Files (*.*)'}, ... |
---|
3845 | 'Pick a file',filebase); |
---|
3846 | filegrid=fullfile(PathName,FileName); |
---|
3847 | set(handles.grid_patch1,'string',filegrid); |
---|
3848 | % set(handles.grid_patch2,'string',filegrid |
---|
3849 | |
---|
3850 | %------------------------------------------------------------------------ |
---|
3851 | % --- Executes on button press in get_gridpatch2. |
---|
3852 | function get_gridpatch2_Callback(hObject, eventdata, handles) |
---|
3853 | %------------------------------------------------------------------------ |
---|
3854 | |
---|
3855 | %------------------------------------------------------------------------ |
---|
3856 | function enable_civ1(handles,state) |
---|
3857 | %------------------------------------------------------------------------ |
---|
3858 | if state |
---|
3859 | RootName=get(handles.RootName,'String'); |
---|
3860 | if isempty(RootName) |
---|
3861 | msgbox_uvmat('ERROR','No input file') |
---|
3862 | return |
---|
3863 | end |
---|
3864 | set(handles.Civ1,'Visible','on') |
---|
3865 | set(handles.PairIndices,'Visible','on') |
---|
3866 | % set(handles.frame_civ1,'BackgroundColor',[1 1 0]) |
---|
3867 | % set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) |
---|
3868 | % set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) |
---|
3869 | else |
---|
3870 | set(handles.Civ1,'Visible','off') |
---|
3871 | % set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3872 | % set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3873 | % set(handles.frame_grid_civ1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3874 | end |
---|
3875 | |
---|
3876 | % set(handles.num_Bx,'Visible',state) |
---|
3877 | % set(handles.num_By,'Visible',state) |
---|
3878 | % set(handles.num_Searchx,'Visible',state) |
---|
3879 | % set(handles.num_Searchy,'Visible',state) |
---|
3880 | % set(handles.num_Shiftx,'Visible',state) |
---|
3881 | % set(handles.num_Shifty,'Visible',state) |
---|
3882 | % set(handles.num_Rho,'Visible',state) |
---|
3883 | % set(handles.num_Dx,'Visible',state) |
---|
3884 | % set(handles.num_Dy,'Visible',state) |
---|
3885 | % set(handles.SearchRange,'Visible',state) |
---|
3886 | % set(handles.u_title,'Visible',state) |
---|
3887 | % set(handles.v_title,'Visible',state) |
---|
3888 | % set(handles.min_title,'Visible',state) |
---|
3889 | % set(handles.max_title,'Visible',state) |
---|
3890 | % set(handles.umin,'Visible',state) |
---|
3891 | % set(handles.umax,'Visible',state) |
---|
3892 | % set(handles.vmin,'Visible',state) |
---|
3893 | % set(handles.vmax,'Visible',state) |
---|
3894 | % set(handles.txt_GridName,'Visible',state) |
---|
3895 | % set(handles.txt_MaskName,'Visible',state) |
---|
3896 | % set(handles.CheckGrid,'Visible',state) |
---|
3897 | % set(handles.CheckMask,'Visible',state) |
---|
3898 | % set(handles.parameters,'Visible',state) |
---|
3899 | % set(handles.grid,'Visible',state) |
---|
3900 | % set(handles.num_Dx,'Visible',state) |
---|
3901 | % set(handles.num_Dy,'Visible',state) |
---|
3902 | % set(handles.check_Threshold,'Visible',state) |
---|
3903 | % if isequal(state,'off') |
---|
3904 | % set(handles.num_MinIma,'Visible','off') |
---|
3905 | % set(handles.num_MaxIma,'Visible','off') |
---|
3906 | % set(handles.check_Threshold,'Value',0) |
---|
3907 | % end |
---|
3908 | % set(handles.dx_civ1_title,'Visible',state) |
---|
3909 | % set(handles.dy_civ1_title,'Visible',state) |
---|
3910 | % set(handles.ImaThreshold_title,'Visible',state) |
---|
3911 | % set(handles.ib_title,'Visible',state) |
---|
3912 | % set(handles.is_title,'Visible',state) |
---|
3913 | % set(handles.shift_title,'Visible',state) |
---|
3914 | % set(handles.rho_title,'Visible',state) |
---|
3915 | % set(handles.TestCiv1,'Visible',state) |
---|
3916 | %set(handles.ListPairMode,'Visible',state) |
---|
3917 | |
---|
3918 | %------------------------------------------------------------------------ |
---|
3919 | function enable_fix1(handles,state) |
---|
3920 | %------------------------------------------------------------------------ |
---|
3921 | |
---|
3922 | if isequal(state,0) |
---|
3923 | state='off'; |
---|
3924 | end |
---|
3925 | if isequal(state,1) |
---|
3926 | state='on'; |
---|
3927 | RootName=get(handles.RootName,'String'); |
---|
3928 | if isempty(RootName) |
---|
3929 | msgbox_uvmat('ERROR','No input file') |
---|
3930 | return |
---|
3931 | end |
---|
3932 | end |
---|
3933 | if isequal(state,'on') |
---|
3934 | set(handles.Fix1,'Visible','on') |
---|
3935 | % set(handles.frame_fix1,'BackgroundColor',[1 1 0]) |
---|
3936 | else |
---|
3937 | set(handles.Fix1,'Visible','off') |
---|
3938 | %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3939 | end |
---|
3940 | % % set(handles.REMOVE,'Visible',state) |
---|
3941 | % set(handles.CheckFmin2,'Visible',state) |
---|
3942 | % set(handles.CheckF2,'Visible',state) |
---|
3943 | % set(handles.CheckF3,'Visible',state) |
---|
3944 | % set(handles.num_MinCorr,'Visible',state) |
---|
3945 | % set(handles.thresh_vecC_title,'Visible',state) |
---|
3946 | % set(handles.num_MinVel,'Visible',state) |
---|
3947 | % set(handles.TitleMinVel,'Visible',state) |
---|
3948 | % set(handles.txt_MaskName,'Visible',state) |
---|
3949 | % set(handles.CheckMask,'Visible',state) |
---|
3950 | % set(handles.get_ref_fix1,'Visible',state) |
---|
3951 | % set(handles.ref_fix1,'Visible',state) |
---|
3952 | % set(handles.num_MinVel,'Visible',state) |
---|
3953 | % set(handles.field_ref1,'Visible',state) |
---|
3954 | |
---|
3955 | %------------------------------------------------------------------------ |
---|
3956 | function enable_patch1(handles,state) |
---|
3957 | %------------------------------------------------------------------------ |
---|
3958 | if state |
---|
3959 | RootName=get(handles.RootName,'String'); |
---|
3960 | if isempty(RootName) |
---|
3961 | msgbox_uvmat('ERROR','No input file') |
---|
3962 | return |
---|
3963 | end |
---|
3964 | set(handles.Patch1,'Visible','on') |
---|
3965 | else |
---|
3966 | set(handles.Patch1,'Visible','off') |
---|
3967 | end |
---|
3968 | return |
---|
3969 | set(handles.frame_patch1,'BackgroundColor',[1 1 0]) |
---|
3970 | set(handles.rho_patch1,'Visible','on') |
---|
3971 | set(handles.rho_text1,'Visible','on') |
---|
3972 | if get(handles.ListPairMode,'Value')==2 |
---|
3973 | set(handles.thresh_patch1,'Visible','on') |
---|
3974 | set(handles.thresh_text1,'Visible','on') |
---|
3975 | end |
---|
3976 | set(handles.subdomain_patch1,'Visible','on') |
---|
3977 | set(handles.subdomain_text1,'Visible','on') |
---|
3978 | set(handles.nx_patch1,'Visible','on') |
---|
3979 | set(handles.num_Ny,'Visible','on') |
---|
3980 | set(handles.nx_patch1_title,'Visible','on') |
---|
3981 | set(handles.ny_patch1_title,'Visible','on') |
---|
3982 | % if ~isempty(patch_newBin) |
---|
3983 | set(handles.test_interp,'Visible','off'); |
---|
3984 | stereo_test=get(handles.ListCompareMode,'Value'); |
---|
3985 | if stereo_test==3 |
---|
3986 | set(handles.test_stereo1,'Visible','on') |
---|
3987 | end |
---|
3988 | % end |
---|
3989 | %set(handles.get_gridpatch1,'Visible','on') |
---|
3990 | %set(handles.grid_patch1,'string','none'); |
---|
3991 | %set(handles.grid_patch1,'Visible','on') |
---|
3992 | |
---|
3993 | % %------------------------------------------------------------------------ |
---|
3994 | % function desable_patch1(handles) |
---|
3995 | % %------------------------------------------------------------------------ |
---|
3996 | % return |
---|
3997 | % set(handles.frame_patch1,'BackgroundColor',[0.831 0.816 0.784]) |
---|
3998 | % set(handles.rho_patch1,'Visible','off') |
---|
3999 | % set(handles.rho_text1,'Visible','off') |
---|
4000 | % set(handles.thresh_patch1,'Visible','off') |
---|
4001 | % set(handles.thresh_text1,'Visible','off') |
---|
4002 | % set(handles.subdomain_patch1,'Visible','off') |
---|
4003 | % set(handles.subdomain_text1,'Visible','off') |
---|
4004 | % set(handles.nx_patch1,'Visible','off') |
---|
4005 | % set(handles.num_Ny,'Visible','off') |
---|
4006 | % set(handles.nx_patch1_title,'Visible','off') |
---|
4007 | % set(handles.ny_patch1_title,'Visible','off') |
---|
4008 | % set(handles.test_stereo1,'Visible','off') |
---|
4009 | % %set(handles.test_interp,'Visible','off') |
---|
4010 | % %set(handles.get_gridpatch1,'Visible','off') |
---|
4011 | % %set(handles.grid_patch1,'Visible','off') |
---|
4012 | |
---|
4013 | %------------------------------------------------------------------------ |
---|
4014 | function enable_civ2(handles,state) |
---|
4015 | %------------------------------------------------------------------------ |
---|
4016 | if state |
---|
4017 | RootName=get(handles.RootName,'String'); |
---|
4018 | if isempty(RootName) |
---|
4019 | msgbox_uvmat('ERROR','No input file') |
---|
4020 | return |
---|
4021 | end |
---|
4022 | set(handles.Civ2,'Visible','on') |
---|
4023 | set(handles.ListSubdirCiv2,'Visible','on') |
---|
4024 | set(handles.SubdirCiv2,'Visible','on') |
---|
4025 | set(handles.TitleSubdirCiv2,'Visible','on') |
---|
4026 | else |
---|
4027 | set(handles.Civ2,'Visible','off') |
---|
4028 | end |
---|
4029 | |
---|
4030 | % |
---|
4031 | % set(handles.num_Bx,'Visible',state) |
---|
4032 | % set(handles.num_By,'Visible',state) |
---|
4033 | % set(handles.CheckDecimal,'Visible',state) |
---|
4034 | % set(handles.CheckDeformation,'Visible',state) |
---|
4035 | % set(handles.num_Rho,'Visible',state) |
---|
4036 | % set(handles.num_Dx,'Visible',state) |
---|
4037 | % set(handles.num_Dy,'Visible',state) |
---|
4038 | % set(handles.CheckGrid,'Visible',state) |
---|
4039 | % set(handles.CheckMask,'Visible',state) |
---|
4040 | % set(handles.parameters,'Visible',state) |
---|
4041 | % set(handles.grid,'Visible',state) |
---|
4042 | % set(handles.parameters_text,'Visible',state) |
---|
4043 | % set(handles.grid_text,'Visible',state) |
---|
4044 | % set(handles.txt_GridName,'Visible',state) |
---|
4045 | % set(handles.txt_Mask,'Visible',state) |
---|
4046 | % set(handles.dx_civ2_title,'Visible',state) |
---|
4047 | % set(handles.dy_civ2_title,'Visible',state) |
---|
4048 | % set(handles.ibx_civ2_text,'Visible',state) |
---|
4049 | % set(handles.rho_civ2_title,'Visible',state) |
---|
4050 | % set(handles.ImaThreshold2,'Visible',state) |
---|
4051 | % set(handles.ImaThreshold_title2,'Visible',state) |
---|
4052 | % if isequal(state,'off') |
---|
4053 | % set(handles.num_MinIma,'Visible','off') |
---|
4054 | % set(handles.num_MaxIma,'Visible','off') |
---|
4055 | % set(handles.ImaThreshold2,'Value',0) |
---|
4056 | % if isequal(get(handles.CheckFix2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
4057 | % set(handles.ListPairCiv2,'Visible','off') |
---|
4058 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
4059 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
4060 | % set(handles.dt_unit_civ2,'Visible','off') |
---|
4061 | % %set(handles.ref_i_civ2,'Visible','off') |
---|
4062 | % set(handles.i_ref_civ2_title,'Visible','off') |
---|
4063 | % set(handles.j_ref_civ2_title,'Visible','off') |
---|
4064 | % set(handles.ref_j_civ2,'Visible','off') |
---|
4065 | % end |
---|
4066 | % else |
---|
4067 | % set(handles.ListPairCiv2,'Visible','on') |
---|
4068 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
4069 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
4070 | % set(handles.dt_unit_civ2,'Visible','on') |
---|
4071 | % % set(handles.ref_i_civ2,'Visible','on') |
---|
4072 | % set(handles.i_ref_civ2_title,'Visible','on') |
---|
4073 | % set(handles.j_ref_civ2_title,'Visible','on') |
---|
4074 | % set(handles.ref_j_civ2,'Visible','on') |
---|
4075 | % end |
---|
4076 | % set(handles.rho_civ2_title,'Visible',state) |
---|
4077 | |
---|
4078 | %------------------------------------------------------------------------ |
---|
4079 | function enable_fix2(handles,state) |
---|
4080 | %------------------------------------------------------------------------ |
---|
4081 | % if isequal(state,'on') |
---|
4082 | % set(handles.Fix2,'Visible','on') |
---|
4083 | % |
---|
4084 | % % set(handles.frame_civ2,'BackgroundColor',[1 1 0]) |
---|
4085 | % % set(handles.frame_para_civ2,'BackgroundColor',[1 1 0]) |
---|
4086 | % % set(handles.frame_grid_civ2,'BackgroundColor',[1 1 0]) |
---|
4087 | % % set(handles.frame_subdirciv2,'BackgroundColor',[1 1 0]) |
---|
4088 | % else |
---|
4089 | if state |
---|
4090 | RootName=get(handles.RootName,'String'); |
---|
4091 | if isempty(RootName) |
---|
4092 | msgbox_uvmat('ERROR','No input file') |
---|
4093 | return |
---|
4094 | end |
---|
4095 | set(handles.Fix2,'Visible','on') |
---|
4096 | else |
---|
4097 | set(handles.Fix2,'Visible','off') |
---|
4098 | end |
---|
4099 | |
---|
4100 | % set(handles.frame_fix2,'BackgroundColor',[1 1 0]) |
---|
4101 | % set(handles.REMOVE2,'Visible','on') |
---|
4102 | % set(handles.CheckFmin2,'Visible','on') |
---|
4103 | % set(handles.CheckF4,'Visible','on') |
---|
4104 | % set(handles.CheckF3,'Visible','on') |
---|
4105 | % set(handles.num_MinCorr,'Visible','on') |
---|
4106 | % set(handles.thresh_vec2C_text,'Visible','on') |
---|
4107 | % set(handles.num_MinVel,'Visible','on') |
---|
4108 | % set(handles.TitleMinVel,'Visible','on') |
---|
4109 | % set(handles.txt_MaskName,'Visible','on') |
---|
4110 | % set(handles.CheckMask,'Visible','on') |
---|
4111 | % set(handles.ListPairCiv2,'Visible','on') |
---|
4112 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
4113 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
4114 | % set(handles.get_ref_fix2,'Visible','on') |
---|
4115 | % set(handles.ref_fix2,'Visible','on') |
---|
4116 | % set(handles.num_MinVel,'Visible','on') |
---|
4117 | % set(handles.field_ref2,'Visible','on') |
---|
4118 | |
---|
4119 | % %------------------------------------------------------------------------ |
---|
4120 | % function desable_fix2(handles) |
---|
4121 | % %------------------------------------------------------------------------ |
---|
4122 | % set(handles.frame_fix2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4123 | % set(handles.REMOVE2,'Visible','off') |
---|
4124 | % set(handles.CheckFmin2,'Visible','off') |
---|
4125 | % set(handles.CheckF4,'Visible','off') |
---|
4126 | % set(handles.CheckF3,'Visible','off') |
---|
4127 | % set(handles.num_MinCorr,'Visible','off') |
---|
4128 | % set(handles.thresh_vec2C_text,'Visible','off') |
---|
4129 | % set(handles.num_MinVel,'Visible','off') |
---|
4130 | % set(handles.TitleMinVel,'Visible','off') |
---|
4131 | % set(handles.txt_MaskName,'Visible','off') |
---|
4132 | % set(handles.CheckMask,'Visible','off') |
---|
4133 | % set(handles.get_ref_fix2,'Visible','off') |
---|
4134 | % set(handles.ref_fix2,'Visible','off') |
---|
4135 | % set(handles.num_MinVel,'Visible','off') |
---|
4136 | % set(handles.field_ref2,'Visible','off') |
---|
4137 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckPatch2,'Value'),0) |
---|
4138 | % set(handles.ListPairCiv2,'Visible','off') |
---|
4139 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
4140 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
4141 | % end |
---|
4142 | |
---|
4143 | %------------------------------------------------------------------------ |
---|
4144 | function enable_patch2(handles,state) |
---|
4145 | %------------------------------------------------------------------------ |
---|
4146 | if state |
---|
4147 | RootName=get(handles.RootName,'String'); |
---|
4148 | if isempty(RootName) |
---|
4149 | msgbox_uvmat('ERROR','No input file') |
---|
4150 | return |
---|
4151 | end |
---|
4152 | set(handles.Patch2,'Visible','on') |
---|
4153 | else |
---|
4154 | set(handles.Patch2,'Visible','off') |
---|
4155 | end |
---|
4156 | % set(handles.frame_patch2,'BackgroundColor',[1 1 0]) |
---|
4157 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
4158 | % set(handles.num_SmoothingParam,'Visible','on') |
---|
4159 | % set(handles.num_MaxDiff,'Visible','on') |
---|
4160 | % set(handles.thresh_text2,'Visible','on') |
---|
4161 | % set(handles.num_SubdomainSize,'Visible','on') |
---|
4162 | % set(handles.subdomain_text2,'Visible','on') |
---|
4163 | % set(handles.num_Nx,'Visible','on') |
---|
4164 | % set(handles.num_Ny,'Visible','on') |
---|
4165 | % set(handles.nx_patch2_title,'Visible','on') |
---|
4166 | % set(handles.ny_patch2_title,'Visible','on') |
---|
4167 | % % set(handles.get_gridpatch2,'Visible','on') |
---|
4168 | % % set(handles.grid_patch2,'Visible','on') |
---|
4169 | % set(handles.ListPairCiv2,'Visible','on') |
---|
4170 | % set(handles.txt_SubdirCiv2,'Visible','on') |
---|
4171 | % set(handles.TitleSubdirCiv2,'Visible','on') |
---|
4172 | % stereo_test=get(handles.ListCompareMode,'Value'); |
---|
4173 | % if stereo_test==3 |
---|
4174 | % set(handles.CheckStereo,'Visible','on') |
---|
4175 | % end |
---|
4176 | |
---|
4177 | % %------------------------------------------------------------------------ |
---|
4178 | % function desable_patch2(handles) |
---|
4179 | % %------------------------------------------------------------------------ |
---|
4180 | % %set(handles.checkpatch2,'Visible','off') |
---|
4181 | % return |
---|
4182 | % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) |
---|
4183 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
4184 | % set(handles.num_SmoothingParam,'Visible','off') |
---|
4185 | % set(handles.num_MaxDiff,'Visible','off') |
---|
4186 | % set(handles.thresh_text2,'Visible','off') |
---|
4187 | % set(handles.num_SubdomainSize,'Visible','off') |
---|
4188 | % set(handles.subdomain_text2,'Visible','off') |
---|
4189 | % set(handles.num_Nx,'Visible','off') |
---|
4190 | % set(handles.num_Ny,'Visible','off') |
---|
4191 | % set(handles.nx_patch2_title,'Visible','off') |
---|
4192 | % set(handles.ny_patch2_title,'Visible','off') |
---|
4193 | % % set(handles.get_gridpatch2,'Visible','off') |
---|
4194 | % % set(handles.grid_patch2,'Visible','off') |
---|
4195 | % if isequal(get(handles.CheckCiv2,'Value'),0) & isequal(get(handles.CheckFix2,'Value'),0) |
---|
4196 | % set(handles.ListPairCiv2,'Visible','off') |
---|
4197 | % set(handles.txt_SubdirCiv2,'Visible','off') |
---|
4198 | % set(handles.TitleSubdirCiv2,'Visible','off') |
---|
4199 | % end |
---|
4200 | % set(handles.CheckStereo,'Visible','off') |
---|
4201 | %------------------------------------------------------------------------ |
---|
4202 | function enable_pair1(handles,state) |
---|
4203 | %------------------------------------------------------------------------ |
---|
4204 | set(handles.txt_SubdirCiv1,'Visible',state) |
---|
4205 | set(handles.ListSubdirCiv1,'Visible',state) |
---|
4206 | set(handles.TitleSubdirCiv1,'Visible',state) |
---|
4207 | %set(handles.frame_subdirciv1,'Visible',state) |
---|
4208 | set(handles.ListPairCiv1,'Visible',state) |
---|
4209 | set(handles.TitlePairCiv1,'Visible',state) |
---|
4210 | %set(handles.dt_unit,'Visible',state) |
---|
4211 | %set(handles.PAIR_frame,'Visible',state) |
---|
4212 | |
---|
4213 | %------------------------------------------------------------------------ |
---|
4214 | % --- Read the parameters for checkciv1 on the interface |
---|
4215 | % function par=read_param_civ1(handles,filecell) |
---|
4216 | % % not deeden anymore |
---|
4217 | % %------------------------------------------------------------------------ |
---|
4218 | % ibx_val=str2double(get(handles.num_Bx,'String')); |
---|
4219 | % par.ibx=num2str(ibx_val); |
---|
4220 | % iby_val=str2double(get(handles.num_By,'String')); |
---|
4221 | % par.iby=num2str(iby_val); |
---|
4222 | % isx=get(handles.num_Searchx,'String'); |
---|
4223 | % if isnan(str2double(isx)), isx='41'; set(handles.num_Searchx,'String','41'), end; %default |
---|
4224 | % if str2double(isx)<ibx_val+8,isx=num2str(ibx_val+8); set(handles.num_Searchx,'String',num2str(ibx_val+8)); end |
---|
4225 | % isy=get(handles.num_Searchy,'String'); |
---|
4226 | % if isnan(str2double(isy)), isy='41'; set(handles.num_Searchy,'String','41'), end;%default |
---|
4227 | % if str2double(isy)<iby_val+8,isy=num2str(iby_val+8); set(handles.num_Searchy,'String',num2str(iby_val+8)); end |
---|
4228 | % par.isx=get(handles.num_Searchx,'String'); |
---|
4229 | % par.isy=get(handles.num_Searchy,'String'); |
---|
4230 | % par.shiftx=get(handles.num_Shiftx,'String'); |
---|
4231 | % par.shifty=get(handles.num_Shifty,'String'); |
---|
4232 | % if isnan(str2double(par.isx)) |
---|
4233 | % par.isx='41';%default |
---|
4234 | % set(handles.num_Searchx,'String','41'); |
---|
4235 | % end |
---|
4236 | % if isnan(str2double(par.isy)) |
---|
4237 | % par.isy='41'; %default |
---|
4238 | % set(handles.num_Searchy,'String','41'); |
---|
4239 | % end |
---|
4240 | % if isnan(str2double(par.shiftx)) |
---|
4241 | % par.shiftx='0';%default |
---|
4242 | % set(handles.num_Shiftx,'String','0'); |
---|
4243 | % end |
---|
4244 | % if isnan(str2double(par.shifty)) |
---|
4245 | % par.shifty='0'; %default |
---|
4246 | % set(handles.num_Shifty,'String','0'); |
---|
4247 | % end |
---|
4248 | % par.rho=get(handles.num_Rho,'String'); |
---|
4249 | % if isequal(get(handles.num_Rho,'Style'),'popupmenu') |
---|
4250 | % index=get(handles.num_Rho,'Value'); |
---|
4251 | % par.rho=par.rho{index}; |
---|
4252 | % end |
---|
4253 | % dummy=get(handles.num_Dx,'String'); |
---|
4254 | % par.dx=dummy{1}; |
---|
4255 | % dummy=get(handles.num_Dy,'String'); |
---|
4256 | % par.dy=dummy{1}; |
---|
4257 | % if isnan(str2double(par.dx)) |
---|
4258 | % if isempty(get(handles.txt_GridName,'String')); |
---|
4259 | % par.dx='0'; %just read by civ program, not used |
---|
4260 | % else |
---|
4261 | % par.dx='20';%default |
---|
4262 | % set(handles.num_Dx,'String','20'); |
---|
4263 | % end |
---|
4264 | % end |
---|
4265 | % if isnan(str2double(par.dy)) |
---|
4266 | % if isempty(get(handles.txt_GridName,'String')); |
---|
4267 | % par.dy='0';%just read by civ program, not used |
---|
4268 | % else |
---|
4269 | % par.dy='20';%default |
---|
4270 | % set(handles.dy_civ1_title,'String','20'); |
---|
4271 | % end |
---|
4272 | % end |
---|
4273 | % par.pxcmx='1'; %velocities are expressed in pixel dispalcement |
---|
4274 | % par.pxcmy='1'; |
---|
4275 | % % if exist('file_ima','var') |
---|
4276 | % A=imread(filecell.ima1.civ1{1,1});%read the first image to get the size |
---|
4277 | % sizim=size(A); |
---|
4278 | % par.npx=num2str(sizim(2)); |
---|
4279 | % par.npy=num2str(sizim(1)); |
---|
4280 | % %TODO : civ should not need npx and npy |
---|
4281 | % |
---|
4282 | % |
---|
4283 | % % end |
---|
4284 | % %time=get(handles.RootName,'UserData'); %get the set of times |
---|
4285 | % dummy=get(handles.txt_GridName,'String'); |
---|
4286 | % par.gridname=dummy{1}; |
---|
4287 | % par.gridflag='y'; |
---|
4288 | % if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
4289 | % par.gridname='nogrid'; |
---|
4290 | % par.gridflag='n'; |
---|
4291 | % end |
---|
4292 | % |
---|
4293 | |
---|
4294 | |
---|
4295 | %------------------------------------------------------------------------ |
---|
4296 | function par=read_param_civ2(handles,file_ima) |
---|
4297 | %------------------------------------------------------------------------ |
---|
4298 | par.ibx=get(handles.num_Bx,'String'); |
---|
4299 | par.iby=get(handles.num_By,'String'); |
---|
4300 | par.rho=get(handles.num_Rho,'String'); |
---|
4301 | par.decimal=int2str(get(handles.CheckDecimal,'Value')); |
---|
4302 | par.deformation=int2str(get(handles.CheckDeformation,'Value')); |
---|
4303 | par.dx=get(handles.num_Dx,'String'); |
---|
4304 | par.dy=get(handles.num_Dy,'String'); |
---|
4305 | if isnan(str2double(par.dx)) |
---|
4306 | if isempty(get(handles.txt_GridName,'String')); |
---|
4307 | par.dx='0'; %just read by civ program, not used |
---|
4308 | else |
---|
4309 | par.dx='20';%default |
---|
4310 | set(handles.num_Dx,'String','20'); |
---|
4311 | end |
---|
4312 | end |
---|
4313 | if isnan(str2double(par.dy)) |
---|
4314 | if isempty(get(handles.txt_GridName,'String')); |
---|
4315 | par.dy='0';%just read by civ program, not used |
---|
4316 | else |
---|
4317 | par.dy='20';%default |
---|
4318 | set(handles.num_Dy,'String','20'); |
---|
4319 | end |
---|
4320 | end |
---|
4321 | par.pxcmx='1'; |
---|
4322 | par.pxcmy='1'; |
---|
4323 | A=imread(file_ima);%read the first image to get the size |
---|
4324 | sizim=size(A); |
---|
4325 | par.npx=num2str(sizim(2)); |
---|
4326 | par.npy=num2str(sizim(1)); |
---|
4327 | %time=get(handles.RootName,'UserData'); %get the set of times |
---|
4328 | par.gridname=get(handles.txt_GridName,'String'); |
---|
4329 | par.gridflag='y'; |
---|
4330 | if strcmp(par.gridname,'')|| isempty(par.gridname) |
---|
4331 | par.gridname='nogrid'; |
---|
4332 | par.gridflag='n'; |
---|
4333 | end |
---|
4334 | |
---|
4335 | function cmd_CIV1=CIV1_CMD(filename,param) |
---|
4336 | %TODO : include filename in par_civ1 |
---|
4337 | %------------------------------------------------------------------------ |
---|
4338 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4339 | |
---|
4340 | %changes : filename_cmx -> filename ( no extension ) |
---|
4341 | |
---|
4342 | filename=regexprep(filename,'.nc',''); |
---|
4343 | |
---|
4344 | if isequal(Param.Civ1.Dt,'0') |
---|
4345 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
4346 | end |
---|
4347 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
4348 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
4349 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
4350 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
4351 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4352 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4353 | fprintf(fid, ['XX' '\n' ]); |
---|
4354 | fprintf(fid, ['Mask ' Param.Civ1.maskflag '\n' ]); |
---|
4355 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.maskname,'\\','\\\\') '\n' ]); |
---|
4356 | fprintf(fid, ['ImageSize ' Param.Civ1.npx ' ' Param.Civ1.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
4357 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ1.ibx ' ' Param.Civ1.iby '\n' ]); |
---|
4358 | fprintf(fid, ['SearchBoxeSize ' Param.Civ1.isx ' ' Param.Civ1.isy '\n' ]); |
---|
4359 | fprintf(fid, ['RO ' Param.Civ1.rho '\n' ]); |
---|
4360 | fprintf(fid, ['GridSpacing ' Param.Civ1.dx ' ' Param.Civ1.dy '\n' ]); |
---|
4361 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4362 | fprintf(fid, ['Dt_TO ' Param.Civ1.Dt ' ' Param.Civ1.T0 '\n' ]); |
---|
4363 | fprintf(fid, ['PixCmXY ' Param.Civ1.pxcmx ' ' Param.Civ1.pxcmy '\n' ]); |
---|
4364 | fprintf(fid, ['XX 1' '\n' ]); |
---|
4365 | fprintf(fid, ['ShiftXY ' Param.Civ1.shiftx ' ' Param.Civ1.shifty '\n' ]); |
---|
4366 | fprintf(fid, ['Grid ' Param.Civ1.gridflag '\n' ]); |
---|
4367 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.gridname,'\\','\\\\') '\n' ]); |
---|
4368 | fprintf(fid, ['XX 85' '\n' ]); |
---|
4369 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4370 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4371 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
4372 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
4373 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
4374 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
4375 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
4376 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
4377 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
4378 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
4379 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
4380 | fclose(fid); |
---|
4381 | |
---|
4382 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
4383 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
4384 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
4385 | if(isunix) |
---|
4386 | cmd_CIV1=['cp -f ' filename '.civ1.cmx ' filename '.cmx']; |
---|
4387 | cmd_CIV1=[cmd_CIV1 '\n'... |
---|
4388 | Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
4389 | cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
4390 | % cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv1.cmx' '\n'];%rename .cmx as .checkciv1.cmx |
---|
4391 | else %Windows system |
---|
4392 | % flname=regexprep(flname,'\\','\\\\'); |
---|
4393 | % cmd=[cmd 'copy /Y "' flname '.checkciv1.cmx" "' flname '.cmx"\n']; |
---|
4394 | % filename=regexprep(filename,'\\','\\\\'); |
---|
4395 | cmd_CIV1=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx"'];% copy the .civ1.cmx parameter file to .cmx |
---|
4396 | cmd_CIV1=[cmd_CIV1 '\n "' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
4397 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
4398 | cmd_CIV1=[cmd_CIV1 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
4399 | |
---|
4400 | % cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv1.cmx"']; |
---|
4401 | end |
---|
4402 | |
---|
4403 | %------------------------------------------------------------------------ |
---|
4404 | % --- CheckCiv1 Unified |
---|
4405 | function xml_civ1_parameters=CIV1_CMD_Unified(filename,namelog,par) |
---|
4406 | %------------------------------------------------------------------------ |
---|
4407 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4408 | %global CivBin%name of the executable for checkciv1 calculation |
---|
4409 | |
---|
4410 | civ1.image1=par.filename_ima_a; |
---|
4411 | civ1.image2=par.filename_ima_b; |
---|
4412 | civ1.imageSize_X=par.npx; |
---|
4413 | civ1.imageSize_Y=par.npy; |
---|
4414 | civ1.outputFileName=[filename '.nc']; |
---|
4415 | civ1.correlationBoxesSize_X=par.ibx; |
---|
4416 | civ1.correlationBoxesSize_Y=par.iby; |
---|
4417 | civ1.searchBoxesSize_X=par.isx; |
---|
4418 | civ1.searchBoxesSize_Y=par.isy; |
---|
4419 | civ1.globalShift_X=par.shiftx; |
---|
4420 | civ1.globalShift_Y=par.shifty; |
---|
4421 | civ1.ro=par.rho; |
---|
4422 | civ1.hart='y'; |
---|
4423 | if isequal(par.gridflag,'y') |
---|
4424 | civ1.grid=par.gridname; |
---|
4425 | else |
---|
4426 | civ1.grid='n'; |
---|
4427 | civ1.gridSpacing_X=par.dx; |
---|
4428 | civ1.gridSpacing_Y=par.dy; |
---|
4429 | end |
---|
4430 | if isequal(par.maskflag,'y') |
---|
4431 | civ1.mask=par.maskname; |
---|
4432 | end |
---|
4433 | civ1.dt=par.Dt; |
---|
4434 | civ1.unit='pixel'; |
---|
4435 | civ1.absolut_time_T0=par.T0; |
---|
4436 | civ1.pixcmx=par.pxcmx; |
---|
4437 | civ1.pixcmy=par.pxcmy; |
---|
4438 | civ1.convectFlow='n'; |
---|
4439 | |
---|
4440 | xml_civ1_parameters=civ1; |
---|
4441 | |
---|
4442 | %------------------------------------------------------------------------ |
---|
4443 | % --- CheckCiv2 Unified |
---|
4444 | function civ2=CIV2_CMD_Unified(filename,namelog,par) |
---|
4445 | %------------------------------------------------------------------------ |
---|
4446 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4447 | %global CivBin%name of the executable for checkciv1 calculation |
---|
4448 | |
---|
4449 | filename=regexprep(filename,'.nc',''); |
---|
4450 | |
---|
4451 | civ2.image1=par.filename_ima_a; |
---|
4452 | civ2.image2=par.filename_ima_b; |
---|
4453 | civ2.imageSize_X=par.npx; |
---|
4454 | civ2.imageSize_Y=par.npy; |
---|
4455 | civ2.inputFileName=[par.filename_nc1 '.nc']; |
---|
4456 | civ2.outputFileName=[filename '.nc']; |
---|
4457 | civ2.correlationBoxesSize_X=par.ibx; |
---|
4458 | civ2.correlationBoxesSize_Y=par.iby; |
---|
4459 | civ2.ro=par.rho; |
---|
4460 | %checkciv2.decimalShift=par.CheckDecimal; |
---|
4461 | %checkciv2.CheckDeformation=par.CheckDeformation; |
---|
4462 | if isequal(par.decimal,'1') |
---|
4463 | civ2.decimalShift='y'; |
---|
4464 | else |
---|
4465 | civ2.decimalShift='n'; |
---|
4466 | end |
---|
4467 | if isequal(par.deformation,'1') |
---|
4468 | civ2.deformation='y'; |
---|
4469 | else |
---|
4470 | civ2.deformation='n'; |
---|
4471 | end |
---|
4472 | if isequal(par.gridflag,'y') |
---|
4473 | civ2.grid=par.gridname; |
---|
4474 | else |
---|
4475 | civ2.grid='n'; |
---|
4476 | civ2.gridSpacing_X=par.dx; |
---|
4477 | civ2.gridSpacing_Y=par.dy; |
---|
4478 | end |
---|
4479 | civ2.gridSpacing_X='10'; |
---|
4480 | civ2.gridSpacing_Y='10';%NOTE: faut mettre gridSpacing pourque ca tourne, meme si c'est la grille qui est utilisee |
---|
4481 | if isequal(par.maskflag,'y') |
---|
4482 | civ2.mask=par.maskname; |
---|
4483 | else |
---|
4484 | civ2.mask='n'; |
---|
4485 | end |
---|
4486 | civ2.dt=par.Dt; |
---|
4487 | civ2.unit='pixel'; |
---|
4488 | civ2.absolut_time_T0=par.T0; |
---|
4489 | civ2.pixcmx=par.pxcmx; |
---|
4490 | civ2.pixcmy=par.pxcmy; |
---|
4491 | civ2.convectFlow='n'; |
---|
4492 | civ2.pixcmx=par.pxcmx; |
---|
4493 | civ2.pixcmy=par.pxcmy; |
---|
4494 | civ2.convectFlow='n'; |
---|
4495 | |
---|
4496 | %------------------------------------------------------------------------ |
---|
4497 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
4498 | function cmd_CIV2=CIV2_CMD(filename,param) |
---|
4499 | %------------------------------------------------------------------------ |
---|
4500 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
4501 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
4502 | filename=regexprep(filename,'.nc',''); |
---|
4503 | if isequal(Param.Civ2.Dt,'0') |
---|
4504 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
4505 | end |
---|
4506 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
4507 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
4508 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
4509 | if isequal(fid,-1) |
---|
4510 | msgbox_uvmat('ERROR',errormsg) |
---|
4511 | cmd_CIV2=''; |
---|
4512 | return |
---|
4513 | end |
---|
4514 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
4515 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4516 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4517 | fprintf(fid, ['XX' '\n' ]); |
---|
4518 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
4519 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
4520 | fprintf(fid, ['ImageSize ' Param.Civ2.npx ' ' Param.Civ2.npy '\n' ]); %VERIFIER CAS GENERAL ? |
---|
4521 | fprintf(fid, ['CorrelationBoxesSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n' ]); |
---|
4522 | fprintf(fid, ['SearchBoxeSize ' Param.Civ2.ibx ' ' Param.Civ2.iby '\n']); |
---|
4523 | fprintf(fid, ['RO ' Param.Civ2.rho '\n']); |
---|
4524 | fprintf(fid, ['GridSpacing ' Param.Civ2.dx ' ' Param.Civ2.dy '\n']); |
---|
4525 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4526 | fprintf(fid, ['Dt_TO ' Param.Civ2.Dt ' ' Param.Civ2.T0 '\n' ]); |
---|
4527 | fprintf(fid, ['PixCmXY ' Param.Civ2.pxcmx ' ' Param.Civ2.pxcmy '\n' ]); |
---|
4528 | fprintf(fid, ['XX 1' '\n' ]); |
---|
4529 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
4530 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
4531 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
4532 | fprintf(fid, ['XX 85' '\n' ]); |
---|
4533 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4534 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
4535 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
4536 | fprintf(fid, ['DecimalShift ' Param.Civ2.decimal '\n']); |
---|
4537 | fprintf(fid, ['Deformation ' Param.Civ2.deformation '\n']); |
---|
4538 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
4539 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
4540 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
4541 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
4542 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
4543 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
4544 | fclose(fid); |
---|
4545 | |
---|
4546 | if(isunix) |
---|
4547 | cmd_CIV2=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n']; |
---|
4548 | cmd_CIV2=[cmd_CIV2 Param.xml.Civ2Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
4549 | cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];%preserve the log file as .civ2.log |
---|
4550 | % cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.checkciv2.cmx' '\n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
4551 | |
---|
4552 | else |
---|
4553 | filename=regexprep(filename,'\\','\\\\'); |
---|
4554 | cmd_CIV2=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx"']; |
---|
4555 | cmd_CIV2=[cmd_CIV2 '\n "' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file |
---|
4556 | cmd_CIV2=[cmd_CIV2 '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"']; |
---|
4557 | % cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.checkciv2.cmx"']; |
---|
4558 | end |
---|
4559 | |
---|
4560 | |
---|
4561 | %------------------------------------------------------------------------ |
---|
4562 | %--read images and convert them to the uint16 format used for PIV |
---|
4563 | function A=read_image(filename,type_ima,num,movieobject) |
---|
4564 | %------------------------------------------------------------------------ |
---|
4565 | %num is the view number needed for an avi movie |
---|
4566 | switch type_ima |
---|
4567 | case 'movie' |
---|
4568 | A=read(movieobject,num); |
---|
4569 | case 'avi' |
---|
4570 | mov=aviread(filename,num); |
---|
4571 | A=frame2im(mov(1)); |
---|
4572 | case 'multimage' |
---|
4573 | A=imread(filename,num); |
---|
4574 | case 'image' |
---|
4575 | A=imread(filename); |
---|
4576 | end |
---|
4577 | siz=size(A); |
---|
4578 | if length(siz)==3;%color images |
---|
4579 | A=sum(double(A),3); |
---|
4580 | A=uint16(A); |
---|
4581 | end |
---|
4582 | |
---|
4583 | %------------------------------------------------------------------------ |
---|
4584 | function ref_i_Callback(hObject, eventdata, handles) |
---|
4585 | %------------------------------------------------------------------------ |
---|
4586 | mode_list=get(handles.ListPairMode,'String'); |
---|
4587 | mode_value=get(handles.ListPairMode,'Value'); |
---|
4588 | mode=mode_list{mode_value}; |
---|
4589 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4590 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
4591 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
4592 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
4593 | end |
---|
4594 | |
---|
4595 | %------------------------------------------------------------------------ |
---|
4596 | function ref_j_Callback(hObject, eventdata, handles) |
---|
4597 | %------------------------------------------------------------------------ |
---|
4598 | mode_list=get(handles.ListPairMode,'String'); |
---|
4599 | mode_value=get(handles.ListPairMode,'Value'); |
---|
4600 | mode=mode_list{mode_value}; |
---|
4601 | if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
4602 | find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4603 | end |
---|
4604 | if isequal(mode,'series(Dj)') || ... |
---|
4605 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
4606 | find_netcpair_civ2(hObject, eventdata, handles); |
---|
4607 | end |
---|
4608 | |
---|
4609 | %------------------------------------------------------------------------ |
---|
4610 | function ref_i_civ2_Callback(hObject, eventdata, handles) |
---|
4611 | %------------------------------------------------------------------------ |
---|
4612 | mode_list=get(handles.ListPairMode,'String'); |
---|
4613 | mode_value=get(handles.ListPairMode,'Value'); |
---|
4614 | mode=mode_list{mode_value}; |
---|
4615 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4616 | |
---|
4617 | %------------------------------------------------------------------------ |
---|
4618 | function ref_j_civ2_Callback(hObject, eventdata, handles) |
---|
4619 | %------------------------------------------------------------------------ |
---|
4620 | mode_list=get(handles.ListPairMode,'String'); |
---|
4621 | mode_value=get(handles.ListPairMode,'Value'); |
---|
4622 | mode=mode_list{mode_value}; |
---|
4623 | if isequal(mode,'series(Dj)') |
---|
4624 | find_netcpair_civ2(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files |
---|
4625 | end |
---|
4626 | |
---|
4627 | %------------------------------------------------------------------------ |
---|
4628 | % --- Executes on button press in ListCompareMode. |
---|
4629 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
4630 | %------------------------------------------------------------------------ |
---|
4631 | test=get(handles.ListCompareMode,'Value'); |
---|
4632 | if test==2 || test==3 % case 'dispalcemen' or 'stereo PIV' |
---|
4633 | filebase=get(handles.RootName,'String'); |
---|
4634 | browse=get(handlesRootName,'Userdata'); |
---|
4635 | browse.nom_type_ima1=browse.nom_type_ima; |
---|
4636 | set(handlesRootName,'UserData',browse); |
---|
4637 | set(handles.sub_txt,'Visible','on') |
---|
4638 | set(handles.RootName_1,'Visible','On');%mkes the second file input window visible |
---|
4639 | mode_store=get(handles.ListPairMode,'String');%get the present 'mode' |
---|
4640 | set(handles.ListCompareMode,'UserData',mode_store);%store the mode display |
---|
4641 | set(handles.ListPairMode,'Visible','off') |
---|
4642 | if test==2 |
---|
4643 | set(handles.ListPairMode,'Visible','off') |
---|
4644 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
4645 | else |
---|
4646 | set(handles.ListPairMode,'Visible','on') |
---|
4647 | set(handles.ListPairMode,'Value',3) % mode 'Matlab' selected for stereo |
---|
4648 | end |
---|
4649 | |
---|
4650 | %% menuopen an image file with the browser |
---|
4651 | ind_opening=1;%default |
---|
4652 | browse.incr_pair=[0 0]; %default |
---|
4653 | oldfile=get(handles.RootName,'String'); |
---|
4654 | menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)'; |
---|
4655 | '*.xml', '.xml files '; ... |
---|
4656 | '*.civ', '.civ files '; ... |
---|
4657 | '*.png','.png image files'; ... |
---|
4658 | '*.jpg',' jpeg image files'; ... |
---|
4659 | '*.tif','.tif image files'; ... |
---|
4660 | '*.avi;*.AVI','.avi movie files'; ... |
---|
4661 | '*.nc','.netcdf files'; ... |
---|
4662 | '*.*', 'All Files (*.*)'}; |
---|
4663 | [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file of the second series',oldfile); |
---|
4664 | fileinput=[PathName FileName];%complete file name |
---|
4665 | sizf=size(fileinput); |
---|
4666 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
4667 | [path,name,ext]=fileparts(fileinput); |
---|
4668 | [path1]=fileparts(filebase); |
---|
4669 | if isunix |
---|
4670 | [status,path]=system(['readlink ' path]); |
---|
4671 | [status,path1]=system(['readlink ' path1]);% look for the true path in case of symbolic paths |
---|
4672 | end |
---|
4673 | if ~strcmp(path1,path) |
---|
4674 | msgbox_uvmat('ERROR','The second image series must be in the same directory as the first one') |
---|
4675 | return |
---|
4676 | end |
---|
4677 | % set(handles.RootName_1,'String',name); |
---|
4678 | [RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,subdir]=name2display(name); |
---|
4679 | set(handles.RootName_1,'String',RootFile); |
---|
4680 | browse=get(handlesRootName,'UserData'); |
---|
4681 | browse.nom_type_ima_1=nom_type; |
---|
4682 | set(handlesRootName,'UserData',browse) |
---|
4683 | |
---|
4684 | %check image extension |
---|
4685 | if ~strcmp(ext,get(handles.ImaExt,'String')) |
---|
4686 | msgbox_uvmat('ERROR','The second image series must have the same extension name as the first one') |
---|
4687 | return |
---|
4688 | end |
---|
4689 | |
---|
4690 | %% check coincidence of image sizes |
---|
4691 | % ref_i=get(handles.ref_i,'string'); |
---|
4692 | % ref_j=get(handles.ref_j,'string'); |
---|
4693 | % [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc]=set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
4694 | % A=imread(filecell.ima1.checkciv1{1}); |
---|
4695 | % A_1=imread(fileinput); |
---|
4696 | % npxy=size(A); |
---|
4697 | % npxy_1=size(A_1); |
---|
4698 | % if ~isequal(size(A),size(A_1)) |
---|
4699 | % msgbox_uvmat('ERROR','The two input image series do not have the same size') |
---|
4700 | % return |
---|
4701 | % end |
---|
4702 | else |
---|
4703 | set(handles.ListPairMode,'Visible','on') |
---|
4704 | set(handles.RootName_1,'Visible','Off'); |
---|
4705 | set(handles.sub_txt,'Visible','off') |
---|
4706 | set(handles.RootName_1,'String',[]); |
---|
4707 | mode_store=get(handles.ListCompareMode,'UserData'); |
---|
4708 | set(handles.ListPairMode,'Value',1) |
---|
4709 | set(handles.ListPairMode,'String',mode_store) |
---|
4710 | set(handles.test_stereo1,'Value',0) |
---|
4711 | set(handles.CheckStereo,'Value',0) |
---|
4712 | set(handles.ListPairMode,'Value',1) % mode 'civX' selected by default |
---|
4713 | end |
---|
4714 | if test==3 && get(handles.CheckPatch1,'Value') |
---|
4715 | set(handles.test_stereo1,'Visible','on') |
---|
4716 | else |
---|
4717 | set(handles.test_stereo1,'Visible','off') |
---|
4718 | end |
---|
4719 | if test==3 && get(handles.CheckPatch2,'Value') |
---|
4720 | set(handles.CheckStereo,'Visible','on') |
---|
4721 | else |
---|
4722 | set(handles.CheckStereo,'Visible','off') |
---|
4723 | end |
---|
4724 | mode_Callback(hObject, eventdata, handles) |
---|
4725 | |
---|
4726 | %------------------------------------------------------------------------ |
---|
4727 | % --- Executes on button press in get_ref_fix1. |
---|
4728 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
4729 | %------------------------------------------------------------------------ |
---|
4730 | filebase=get(handles.RootName,'String'); |
---|
4731 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4732 | {'*.nc', ' (*.nc)'; |
---|
4733 | '*.nc', 'netcdf files '; ... |
---|
4734 | '*.*', 'All Files (*.*)'}, ... |
---|
4735 | 'Pick a file',filebase); |
---|
4736 | |
---|
4737 | fileinput=[PathName FileName]; |
---|
4738 | sizf=size(fileinput); |
---|
4739 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
4740 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
4741 | ref.filebase=fullfile(Path,File); |
---|
4742 | ref.num_a=stra2num(str_a); |
---|
4743 | ref.num_b=stra2num(str_b); |
---|
4744 | ref.num1=str2double(field_count); |
---|
4745 | ref.num2=str2double(str2); |
---|
4746 | browse=[];%initialisation |
---|
4747 | if ~isequal(ref.ext,'.nc') |
---|
4748 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
4749 | return |
---|
4750 | end |
---|
4751 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
4752 | set(handles.ref_fix1,'UserData',ref) |
---|
4753 | menu_field{1}='civ1'; |
---|
4754 | Data=nc2struct(fileinput,[]); |
---|
4755 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
4756 | menu_field{2}='filter1'; |
---|
4757 | end |
---|
4758 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
4759 | menu_field{3}='civ2'; |
---|
4760 | end |
---|
4761 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
4762 | menu_field{4}='filter2'; |
---|
4763 | end |
---|
4764 | set(handles.field_ref1,'String',menu_field); |
---|
4765 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
4766 | set(handles.num_MinVel,'Value',2); |
---|
4767 | set(handles.num_MinVel,'String','1');%default threshold |
---|
4768 | set(handles.ref_fix1,'Enable','on') |
---|
4769 | |
---|
4770 | %------------------------------------------------------------------------ |
---|
4771 | % --- Executes on button press in get_ref_fix2. |
---|
4772 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
4773 | %------------------------------------------------------------------------ |
---|
4774 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
4775 | filebase=get(handles.RootName,'String'); |
---|
4776 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
4777 | {'*.nc', ' (*.nc)'; |
---|
4778 | '*.nc', 'netcdf files '; ... |
---|
4779 | '*.*', 'All Files (*.*)'}, ... |
---|
4780 | 'Pick a file',filebase); |
---|
4781 | fileinput=[PathName FileName]; |
---|
4782 | sizf=size(fileinput); |
---|
4783 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
4784 | [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
4785 | ref.filebase=fullfile(Path,File); |
---|
4786 | ref.num_a=stra2num(str_a); |
---|
4787 | ref.num_b=stra2num(str_b); |
---|
4788 | ref.num1=str2num(field_count); |
---|
4789 | ref.num2=str2num(str2); |
---|
4790 | browse=[];%initialisation |
---|
4791 | if ~isequal(ref.ext,'.nc') |
---|
4792 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
4793 | return |
---|
4794 | end |
---|
4795 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
4796 | set(handles.ref_fix2,'UserData',ref) |
---|
4797 | menu_field{1}='civ1'; |
---|
4798 | Data=nc2struct(fileinput,[]); |
---|
4799 | if isfield(Data,'patch') & isequal(Data.patch,1) |
---|
4800 | menu_field{2}='filter1'; |
---|
4801 | end |
---|
4802 | if isfield(Data,'civ2') & isequal(Data.civ2,1) |
---|
4803 | menu_field{3}='civ2'; |
---|
4804 | end |
---|
4805 | if isfield(Data,'patch2') & isequal(Data.patch2,1) |
---|
4806 | menu_field{4}='filter2'; |
---|
4807 | end |
---|
4808 | set(handles.field_ref2,'String',menu_field); |
---|
4809 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
4810 | set(handles.num_MinVel,'Value',2); |
---|
4811 | set(handles.num_MinVel,'String','1');%default threshold |
---|
4812 | set(handles.ref_fix2,'Enable','on') |
---|
4813 | set(handles.ref_fix2,'Visible','on') |
---|
4814 | set(handles.field_ref2,'Visible','on') |
---|
4815 | else |
---|
4816 | set(handles.ref_fix2,'Visible','off') |
---|
4817 | set(handles.field_ref2,'Visible','off') |
---|
4818 | end |
---|
4819 | |
---|
4820 | %------------------------------------------------------------------------ |
---|
4821 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
4822 | %------------------------------------------------------------------------ |
---|
4823 | set(handles.num_MinVel,'Value',1); |
---|
4824 | set(handles.field_ref1,'Value',1) |
---|
4825 | set(handles.field_ref1,'String',{' '}) |
---|
4826 | set(handles.ref_fix1,'UserData',[]); |
---|
4827 | set(handles.ref_fix1,'String',''); |
---|
4828 | set(handles.thresh_vel1,'String','0'); |
---|
4829 | |
---|
4830 | %------------------------------------------------------------------------ |
---|
4831 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
4832 | %------------------------------------------------------------------------ |
---|
4833 | set(handles.num_MinVel,'Value',1); |
---|
4834 | set(handles.field_ref2,'Value',1) |
---|
4835 | set(handles.field_ref2,'String',{' '}) |
---|
4836 | set(handles.ref_fix2,'UserData',[]); |
---|
4837 | set(handles.ref_fix2,'String',''); |
---|
4838 | set(handles.num_MinVel,'String','0'); |
---|
4839 | |
---|
4840 | %------------------------------------------------------------------------ |
---|
4841 | % --- Executes on button press in test_stereo1. |
---|
4842 | function test_stereo1_Callback(hObject, eventdata, handles) |
---|
4843 | %------------------------------------------------------------------------ |
---|
4844 | if isequal(get(handles.test_stereo1,'Value'),0) |
---|
4845 | set(handles.subdomain_patch1,'Visible','on') |
---|
4846 | set(handles.rho_patch1,'Visible','on') |
---|
4847 | else |
---|
4848 | set(handles.subdomain_patch1,'Visible','off') |
---|
4849 | set(handles.rho_patch1,'Visible','off') |
---|
4850 | end |
---|
4851 | |
---|
4852 | %------------------------------------------------------------------------ |
---|
4853 | % --- Executes on button press in CheckStereo. |
---|
4854 | function StereoCheck_Callback(hObject, eventdata, handles) |
---|
4855 | %------------------------------------------------------------------------ |
---|
4856 | if isequal(get(handles.CheckStereo,'Value'),0) |
---|
4857 | set(handles.num_SubdomainSize,'Visible','on') |
---|
4858 | set(handles.num_SmoothingParam,'Visible','on') |
---|
4859 | else |
---|
4860 | set(handles.num_SubdomainSize,'Visible','off') |
---|
4861 | set(handles.num_SmoothingParam,'Visible','off') |
---|
4862 | end |
---|
4863 | |
---|
4864 | %------------------------------------------------------------------------ |
---|
4865 | % --- Executes on button press in check_Threshold. |
---|
4866 | function ImaThreshold_Callback(hObject, eventdata, handles) |
---|
4867 | %------------------------------------------------------------------------ |
---|
4868 | if isequal(get(handles.check_Threshold,'Value'),1) |
---|
4869 | set(handles.num_MinIma,'Visible','on') |
---|
4870 | set(handles.num_MaxIma,'Visible','on') |
---|
4871 | else |
---|
4872 | set(handles.num_MinIma,'Visible','off') |
---|
4873 | set(handles.num_MaxIma,'Visible','off') |
---|
4874 | end |
---|
4875 | |
---|
4876 | %------------------------------------------------------------------------ |
---|
4877 | % --- Executes on button press in ImaThreshold2. |
---|
4878 | function ImaThreshold2_Callback(hObject, eventdata, handles) |
---|
4879 | %------------------------------------------------------------------------ |
---|
4880 | if isequal(get(handles.ImaThreshold2,'Value'),1) |
---|
4881 | set(handles.num_MinIma,'Visible','on') |
---|
4882 | set(handles.num_MaxIma,'Visible','on') |
---|
4883 | else |
---|
4884 | set(handles.num_MinIma,'Visible','off') |
---|
4885 | set(handles.num_MaxIma,'Visible','off') |
---|
4886 | end |
---|
4887 | |
---|
4888 | %------------------------------------------------------------------------ |
---|
4889 | % --- Executes on button press in TestCiv1: display image correlation function |
---|
4890 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
4891 | %------------------------------------------------------------------------ |
---|
4892 | set(handles.TestCiv1,'BackgroundColor',[1 1 0]) |
---|
4893 | drawnow |
---|
4894 | test_civ1=get(handles.TestCiv1,'Value'); |
---|
4895 | if test_civ1 |
---|
4896 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
4897 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
4898 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
4899 | else |
---|
4900 | ref_j=1;%default |
---|
4901 | end |
---|
4902 | [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]=... |
---|
4903 | set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]); |
---|
4904 | Data.ListVarName={'ny','nx','A'}; |
---|
4905 | Data.VarDimName={'ny','nx',{'ny','nx'}}; |
---|
4906 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
4907 | Data.ny=[size(Data.A,1) 1]; |
---|
4908 | Data.nx=[1 size(Data.A,2)]; |
---|
4909 | par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1}); |
---|
4910 | par_civ1.filename_ima_a=filecell.ima1.civ1{1}; |
---|
4911 | par_civ1.filename_ima_b=filecell.ima2.civ1{1}; |
---|
4912 | par_civ1.T0=0; |
---|
4913 | par_civ1.Dt=1; |
---|
4914 | Param.Civ1=par_civ1; |
---|
4915 | Data=civ_uvmat(Param); |
---|
4916 | Data.ListVarName=[Data.ListVarName {'ny','nx','A'}]; |
---|
4917 | Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}]; |
---|
4918 | Data.A=imread(filecell.ima1.civ1{1}); |
---|
4919 | Data.ny=[size(Data.A,1) 1]; |
---|
4920 | Data.nx=[1 size(Data.A,2)]; |
---|
4921 | hview_field=view_field(Data); |
---|
4922 | set(0,'CurrentFigure',hview_field) |
---|
4923 | hhview_field=guihandles(hview_field); |
---|
4924 | set(hview_field,'CurrentAxes',hhview_field.axes3) |
---|
4925 | ViewData=get(hview_field,'UserData'); |
---|
4926 | ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field |
---|
4927 | ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field |
---|
4928 | ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory |
---|
4929 | ViewData.axes3.Y=Data.Civ1_Y; |
---|
4930 | set(hview_field,'UserData',ViewData) |
---|
4931 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
4932 | if isempty(corrfig) |
---|
4933 | corrfig=figure; |
---|
4934 | set(corrfig,'tag','corrfig') |
---|
4935 | set(corrfig,'name','image correlation') |
---|
4936 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
4937 | end |
---|
4938 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
4939 | else |
---|
4940 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
4941 | if ~isempty(corrfig) |
---|
4942 | delete(corrfig) |
---|
4943 | end |
---|
4944 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
4945 | if ~isempty(hview_field) |
---|
4946 | delete(hview_field) |
---|
4947 | end |
---|
4948 | end |
---|
4949 | |
---|
4950 | function closeview_field(gcbo,eventdata) |
---|
4951 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
4952 | if ~isempty(hview_field) |
---|
4953 | delete(hview_field) |
---|
4954 | end |
---|
4955 | %------------------------------------------------------------------- |
---|
4956 | % --- Executes on button press in status. |
---|
4957 | function status_Callback(hObject, eventdata, handles) |
---|
4958 | %------------------------------------------------------------------- |
---|
4959 | val=get(handles.status,'Value'); |
---|
4960 | if val==0 |
---|
4961 | set(handles.status,'BackgroundColor',[0 1 0]) |
---|
4962 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
4963 | if ~isempty(hfig) |
---|
4964 | delete(hfig) |
---|
4965 | end |
---|
4966 | return |
---|
4967 | end |
---|
4968 | set(handles.status,'BackgroundColor',[1 1 0]) |
---|
4969 | drawnow |
---|
4970 | listtype={'civ1','fix1','patch1','civ2','fix2','patch2'}; |
---|
4971 | Param.CheckCiv1=get(handles.CheckCiv1,'Value'); |
---|
4972 | Param.CheckFix1=get(handles.CheckFix1,'Value'); |
---|
4973 | Param.CheckPatch1=get(handles.CheckPatch1,'Value'); |
---|
4974 | Param.CheckCiv2=get(handles.CheckCiv2,'Value'); |
---|
4975 | Param.CheckFix2=get(handles.CheckFix2,'Value'); |
---|
4976 | Param.CheckPatch2=get(handles.CheckPatch2,'Value'); |
---|
4977 | box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; |
---|
4978 | |
---|
4979 | option_civ=find(box_test,1,'last');%last selected option (non-zero index of box_test) |
---|
4980 | filecell=get(handles.civ,'UserData');%retrieve the list of output files expected for PIV |
---|
4981 | test_new=0; |
---|
4982 | if ~isfield(filecell,'nc') |
---|
4983 | test_new=1; |
---|
4984 | [ref_i,ref_j,errormsg]=find_ref_indices(handles); |
---|
4985 | if ~isempty(errormsg) |
---|
4986 | msgbox_uvmat('ERROR',errormsg) |
---|
4987 | return |
---|
4988 | end |
---|
4989 | filecell=set_civ_filenames(handles,ref_i,ref_j,box_test);%determine the output file expected from the GUI status |
---|
4990 | end |
---|
4991 | if ~isequal(box_test(4:6),[0 0 0]) |
---|
4992 | civ_files=filecell.nc.civ2;%case of civ2 operations |
---|
4993 | else |
---|
4994 | civ_files=filecell.nc.civ1; |
---|
4995 | end |
---|
4996 | [root,filename,ext]=fileparts(civ_files{1}); |
---|
4997 | [rootroot,subdir,extdir]=fileparts(root); |
---|
4998 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
4999 | if isempty(hfig) |
---|
5000 | hfig=figure('DeleteFcn',@stop_status); |
---|
5001 | set(hfig,'name','civ_status') |
---|
5002 | hlist=uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @open_view_field,'tag','list'); |
---|
5003 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','msgbox','Max',2,'String','checking files...'); |
---|
5004 | uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); |
---|
5005 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','OK','FontWeight','bold','FontUnits','normalized','FontSize',0.9,'Callback',@close_GUI); |
---|
5006 | BarPosition=[0.05 0.81 0.01 0.05]; |
---|
5007 | hwaitbar=uicontrol('Style','frame','Units','normalized', 'Position',BarPosition ,'BackgroundColor',[1 0 0],'tag','waitbar'); |
---|
5008 | drawnow |
---|
5009 | end |
---|
5010 | % datnum=[]; |
---|
5011 | Tabchar={}; |
---|
5012 | nbfiles=numel(civ_files); |
---|
5013 | count=0; |
---|
5014 | testrecent=0; |
---|
5015 | while count<nbfiles |
---|
5016 | count=0; |
---|
5017 | datnum=zeros(1,nbfiles); |
---|
5018 | for ifile=1:nbfiles |
---|
5019 | detect=exist(civ_files{ifile},'file'); % check the existence of the file |
---|
5020 | option=0; |
---|
5021 | if detect==0 |
---|
5022 | option_str='not created'; |
---|
5023 | else |
---|
5024 | datfile=dir(civ_files{ifile}); |
---|
5025 | if isfield(datfile,'datenum') |
---|
5026 | datnum(ifile)=datfile.datenum;%only available in recent matlab versions |
---|
5027 | testrecent=1; |
---|
5028 | end |
---|
5029 | filefound(ifile)={datfile.name}; |
---|
5030 | lastfield=''; |
---|
5031 | % check the content netcdf file |
---|
5032 | Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','patch2','fix2','civ2','patch','fix'); |
---|
5033 | if ~isempty(Data.patch2) && isequal(Data.patch2,1) |
---|
5034 | option=6; |
---|
5035 | option_str='patch2'; |
---|
5036 | elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) |
---|
5037 | option=5; |
---|
5038 | option_str='fix2'; |
---|
5039 | elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); |
---|
5040 | option=4; |
---|
5041 | option_str='civ2'; |
---|
5042 | elseif ~isempty(Data.patch) && isequal(Data.patch,1); |
---|
5043 | option=3; |
---|
5044 | option_str='patch1'; |
---|
5045 | elseif ~isempty(Data.fix) && isequal(Data.fix,1); |
---|
5046 | option=2; |
---|
5047 | option_str='fix1'; |
---|
5048 | else |
---|
5049 | option=1; |
---|
5050 | option_str='civ1'; |
---|
5051 | end |
---|
5052 | end |
---|
5053 | if option >= option_civ |
---|
5054 | count=count+1; |
---|
5055 | end |
---|
5056 | [rr,filename,ext]=fileparts(civ_files{ifile}); |
---|
5057 | Tabchar{ifile,1}=[fullfile([subdir extdir],filename) ext '...' option_str]; |
---|
5058 | end |
---|
5059 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
5060 | if isempty(datnum) |
---|
5061 | if testrecent |
---|
5062 | message='no civ result created yet'; |
---|
5063 | else |
---|
5064 | message=''; |
---|
5065 | end |
---|
5066 | else |
---|
5067 | datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files |
---|
5068 | [first,ind]=min(datnum); |
---|
5069 | [last,indlast]=max(datnum); |
---|
5070 | if test_new |
---|
5071 | message='existing file status, no processing launched yet'; |
---|
5072 | else |
---|
5073 | message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... |
---|
5074 | ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; |
---|
5075 | end |
---|
5076 | end |
---|
5077 | hfig=findobj(allchild(0),'name','civ_status'); |
---|
5078 | if isempty(hfig)% the status list has been deleted |
---|
5079 | return |
---|
5080 | else |
---|
5081 | hlist=findobj(hfig,'tag','list'); |
---|
5082 | hmsgbox=findobj(hfig,'tag','msgbox'); |
---|
5083 | hwaitbar=findobj(hfig,'tag','waitbar'); |
---|
5084 | set(hlist,'String',Tabchar) |
---|
5085 | set(hmsgbox,'String', message) |
---|
5086 | if count>0 && ~test_new |
---|
5087 | BarPosition(3)=0.9*count/nbfiles; |
---|
5088 | set(hwaitbar,'Position',BarPosition) |
---|
5089 | end |
---|
5090 | end |
---|
5091 | set(hlist,'UserData',rootroot) |
---|
5092 | pause(10)% wait 10 seconds for next check |
---|
5093 | end |
---|
5094 | |
---|
5095 | |
---|
5096 | %------------------------------------------------------------------------ |
---|
5097 | % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
5098 | function open_view_field(hObject, eventdata) |
---|
5099 | %------------------------------------------------------------------------ |
---|
5100 | list=get(hObject,'String'); |
---|
5101 | index=get(hObject,'Value'); |
---|
5102 | rootroot=get(hObject,'UserData'); |
---|
5103 | filename=list{index}; |
---|
5104 | ind_dot=findstr(filename,'...'); |
---|
5105 | filename=filename(1:ind_dot-1); |
---|
5106 | filename=fullfile(rootroot,filename); |
---|
5107 | delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
5108 | if exist(filename,'file')%visualise the vel field if it exists |
---|
5109 | uvmat(filename) |
---|
5110 | set(gcbo,'Value',1) |
---|
5111 | end |
---|
5112 | |
---|
5113 | %------------------------------------------------------------------------ |
---|
5114 | % launched by pressing OK on the status figure |
---|
5115 | function close_GUI(hObject, eventdata) |
---|
5116 | %------------------------------------------------------------------------ |
---|
5117 | delete(gcbf) |
---|
5118 | |
---|
5119 | %------------------------------------------------------------------------ |
---|
5120 | % launched by deleting the status figure |
---|
5121 | function stop_status(hObject, eventdata) |
---|
5122 | %------------------------------------------------------------------------ |
---|
5123 | hciv=findobj(allchild(0),'tag','civ'); |
---|
5124 | hhciv=guidata(hciv); |
---|
5125 | set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ |
---|
5126 | set(hhciv.status,'BackgroundColor',[0 1 0]) |
---|
5127 | |
---|
5128 | %------------------------------------------------------------------------ |
---|
5129 | % % --- Executes on button press in ListPairMode. |
---|
5130 | % function CivMode_Callback(hObject, eventdata, handles) |
---|
5131 | % %------------------------------------------------------------------------ |
---|
5132 | % Listprog=get(handles.ListPairMode,'String'); |
---|
5133 | % index=get(handles.ListPairMode,'Value'); |
---|
5134 | % prog=Listprog{index}; |
---|
5135 | % switch prog |
---|
5136 | % case 'CivX' |
---|
5137 | % set(handles.thresh_patch1,'Visible','off') |
---|
5138 | % set(handles.thresh_text1,'Visible','off') |
---|
5139 | % set(handles.num_MaxDiff,'Visible','off') |
---|
5140 | % set(handles.thresh_text2,'Visible','off') |
---|
5141 | % set(handles.num_Rho,'Style','edit') |
---|
5142 | % set(handles.num_Rho,'String','1') |
---|
5143 | % set(handles.BATCH,'Enable','on') |
---|
5144 | % case 'CivAll' |
---|
5145 | % if get(handles.CheckPatch1,'Value') |
---|
5146 | % set(handles.thresh_patch1,'Visible','on') |
---|
5147 | % set(handles.thresh_text1,'Visible','on') |
---|
5148 | % end |
---|
5149 | % set(handles.num_Rho,'Style','edit') |
---|
5150 | % set(handles.num_Rho,'String','1') |
---|
5151 | % set(handles.BATCH,'Enable','on') |
---|
5152 | % case 'CivUvmat' |
---|
5153 | % |
---|
5154 | % end |
---|
5155 | |
---|
5156 | |
---|
5157 | % -------------------------------------------------------------------- |
---|
5158 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
5159 | path_civ=fileparts(which ('civ')); |
---|
5160 | helpfile=fullfile(path_civ,'uvmat_doc','uvmat_doc.html'); |
---|
5161 | if isempty(dir(helpfile)) |
---|
5162 | msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
5163 | else |
---|
5164 | addpath (fullfile(path_civ,'uvmat_doc')) |
---|
5165 | web([helpfile '#civ']) |
---|
5166 | end |
---|
5167 | |
---|
5168 | % -------------------------------------------------------------------- |
---|
5169 | function CivX_Callback(hObject, eventdata, handles) |
---|
5170 | %set(handles.thresh_patch1,'Visible','off') |
---|
5171 | set(handles.thresh_text1,'Visible','off') |
---|
5172 | set(handles.num_MaxDiff,'Visible','off') |
---|
5173 | set(handles.thresh_text2,'Visible','off') |
---|
5174 | set(handles.num_Rho,'Style','edit') |
---|
5175 | set(handles.num_Rho,'String','1') |
---|
5176 | set(handles.BATCH,'Enable','on') |
---|
5177 | |
---|
5178 | % -------------------------------------------------------------------- |
---|
5179 | function Matlab_Callback(hObject, eventdata, handles) |
---|
5180 | set(handles.Matlab,'checked','on') |
---|
5181 | set(handles.CivX,'checked','off') |
---|
5182 | if get(handles.CheckPatch1,'Value') |
---|
5183 | set(handles.thresh_patch1,'Visible','on') |
---|
5184 | set(handles.thresh_text1,'Visible','on') |
---|
5185 | end |
---|
5186 | if get(handles.CheckPatch2,'Value') |
---|
5187 | set(handles.num_MaxDiff,'Visible','on') |
---|
5188 | set(handles.thresh_text2,'Visible','on') |
---|
5189 | end |
---|
5190 | set(handles.num_Rho,'Style','popupmenu') |
---|
5191 | set(handles.num_Rho,'Value',1) |
---|
5192 | set(handles.num_Rho,'String',{'1';'2'}) |
---|
5193 | set(handles.BATCH,'Enable','off') |
---|
5194 | |
---|
5195 | % -------------------------------------------------------------------- |
---|
5196 | % --- read a panel with handle 'handle' producing a structure 'struct' |
---|
5197 | function struct=read_panel(handle) |
---|
5198 | hchild=get(handle,'children'); |
---|
5199 | for ichild=1:numel(hchild) |
---|
5200 | if strcmp(get(hchild(ichild),'Visible'),'on') |
---|
5201 | object_style=get(hchild(ichild),'Style'); |
---|
5202 | tag=get(hchild(ichild),'tag'); |
---|
5203 | check_input=1;%default |
---|
5204 | switch object_style |
---|
5205 | case 'edit' |
---|
5206 | switch(tag(1:4)) |
---|
5207 | case 'num_' |
---|
5208 | input=str2double(get(hchild(ichild),'String')); |
---|
5209 | %deal with undefined input: retrieve the default value stored as UserData |
---|
5210 | if isnan(input) |
---|
5211 | input=get(hchild(ichild),'UserData'); |
---|
5212 | set(hchild(ichild),'String',num2str(input)) |
---|
5213 | end |
---|
5214 | case 'txt_' |
---|
5215 | input=get(hchild(ichild),'String'); |
---|
5216 | end |
---|
5217 | key=tag(5:end); |
---|
5218 | case 'checkbox' |
---|
5219 | input=get(hchild(ichild),'Value'); |
---|
5220 | key=tag(7:end); |
---|
5221 | otherwise |
---|
5222 | check_input=0; |
---|
5223 | end |
---|
5224 | if check_input |
---|
5225 | eval(['struct.' key '=input;']) |
---|
5226 | end |
---|
5227 | end |
---|
5228 | end |
---|
5229 | |
---|
5230 | |
---|
5231 | |
---|
5232 | function cmd=cmd_civ1(filename,Param) |
---|
5233 | %TODO : include filename in par_civ1 |
---|
5234 | %------------------------------------------------------------------------ |
---|
5235 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
5236 | |
---|
5237 | %changes : filename_cmx -> filename ( no extension ) |
---|
5238 | |
---|
5239 | filename=regexprep(filename,'.nc',''); |
---|
5240 | |
---|
5241 | if isequal(Param.Civ1.Dt,'0') |
---|
5242 | Param.Civ1.Dt='1' ;%case of 'displacement' mode |
---|
5243 | end |
---|
5244 | Param.Civ1.filename_ima_a=regexprep(Param.Civ1.filename_ima_a,'.png',''); |
---|
5245 | Param.Civ1.filename_ima_b=regexprep(Param.Civ1.filename_ima_b,'.png',''); |
---|
5246 | fid=fopen([filename '.civ1.cmx'],'w'); |
---|
5247 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
5248 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ1.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
5249 | fprintf(fid, ['LastImage ' regexprep(Param.Civ1.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
5250 | fprintf(fid, ['XX' '\n' ]); |
---|
5251 | fprintf(fid, ['Mask ' Param.Civ1.MaskFlag '\n' ]); |
---|
5252 | fprintf(fid, ['MaskName ' regexprep(Param.Civ1.MaskName,'\\','\\\\') '\n' ]); |
---|
5253 | fprintf(fid, ['ImageSize ' num2str(Param.Civ1.npx) ' ' num2str(Param.Civ1.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
5254 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ1.Bx) ' ' num2str(Param.Civ1.By) '\n' ]); |
---|
5255 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]); |
---|
5256 | fprintf(fid, ['RO ' num2str(Param.Civ1.Rho) '\n' ]); |
---|
5257 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); |
---|
5258 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
5259 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.T0) '\n' ]); |
---|
5260 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ1.pxcmx) ' ' num2str(Param.Civ1.pxcmy) '\n' ]); |
---|
5261 | fprintf(fid, ['XX 1' '\n' ]); |
---|
5262 | fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.Shiftx) ' ' num2str(Param.Civ1.Shifty) '\n' ]); |
---|
5263 | fprintf(fid, ['Grid ' Param.Civ1.GridFlag '\n' ]); |
---|
5264 | fprintf(fid, ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]); |
---|
5265 | fprintf(fid, ['XX 85' '\n' ]); |
---|
5266 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
5267 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
5268 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
5269 | fprintf(fid, [ 'DecimalShift 0' '\n' ]); |
---|
5270 | fprintf(fid, ['Deformation 0' '\n' ]); |
---|
5271 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
5272 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
5273 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
5274 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
5275 | fprintf(fid, ['ImageToUse ' Param.Civ1.term_a ' ' Param.Civ1.term_b '\n' ]); % VERIFIER ? |
---|
5276 | fprintf(fid, ['ImageUsedBefore null null' '\n' ]); |
---|
5277 | fclose(fid); |
---|
5278 | |
---|
5279 | % cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file |
---|
5280 | % cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\'); |
---|
5281 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
5282 | if(isunix) |
---|
5283 | cmd=['cp -f ' filename '.civ1.cmx ' filename '.cmx \n '];% the cmx file gives the name to the nc file |
---|
5284 | cmd=[cmd Param.xml.Civ1Bin ' -f ' filename '.cmx >' filename '.civ1.log \n ' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
5285 | % cmd=[cmd '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting |
---|
5286 | % cmd=[cmd '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx |
---|
5287 | cmd=[cmd 'rm ' filename '.cmx']; |
---|
5288 | else %Windows system |
---|
5289 | filename=regexprep(filename,'\\','\\\\'); |
---|
5290 | cmd=['copy /Y "' filename '.civ1.cmx" "' filename '.cmx" \n ']; |
---|
5291 | cmd=[cmd '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\')... |
---|
5292 | '" -f "' filename '.cmx" >"' filename '.civ1.log" \n ' ]; % redirect standard output to the log file |
---|
5293 | % namelog=regexprep(namelog,'\\','\\\\'); |
---|
5294 | % cmd=[cmd '\n ' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"']; %preserve the log file as .civ1.log |
---|
5295 | cmd=[cmd 'del "' filename '.cmx"']; |
---|
5296 | end |
---|
5297 | |
---|
5298 | |
---|
5299 | function cmd=cmd_fix(filename,Param,fixname) |
---|
5300 | %% |
---|
5301 | switch fixname |
---|
5302 | case 'Fix1' |
---|
5303 | fi2_value=num2str(Param.(fixname).CheckF2); |
---|
5304 | case 'Fix2' |
---|
5305 | fi2_value=num2str(Param.(fixname).CheckF4);%need to understand why... |
---|
5306 | end |
---|
5307 | |
---|
5308 | |
---|
5309 | |
---|
5310 | filename=regexprep(filename,'.nc',''); |
---|
5311 | MaskName_string='';%default |
---|
5312 | if Param.(fixname).CheckMask |
---|
5313 | MaskName_string=[' -maskName "' Param.(fixname).MaskName '"']; |
---|
5314 | end |
---|
5315 | MaxVel_string='';%default |
---|
5316 | if ~isempty(Param.(fixname).MaxVel) |
---|
5317 | MaxVel_string=[' -threshV ' num2str(Param.(fixname).MaxVel)]; |
---|
5318 | end |
---|
5319 | if isunix |
---|
5320 | cmd=[Param.xml.FixBin ' -f ' filename '.nc -fi1 ' num2str(Param.(fixname).CheckFmin2) ... |
---|
5321 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
5322 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
5323 | ' >' filename '.' lower(fixname) '.log 2>&1']; |
---|
5324 | else |
---|
5325 | cmd=['"' Param.xml.FixBin '" -f "' filename '.nc" -fi1 ' num2str(Param.(fixname).CheckFmin2)... |
---|
5326 | ' -fi2 ' fi2_value ' -fi3 ' num2str(Param.(fixname).CheckF3) ... |
---|
5327 | ' -threshC ' num2str(Param.(fixname).MinCorr) MaxVel_string MaskName_string... |
---|
5328 | ' > "' filename '.' lower(fixname) '.log"']; |
---|
5329 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
5330 | end |
---|
5331 | |
---|
5332 | |
---|
5333 | function cmd=cmd_patch(filename,Param,patchname) |
---|
5334 | %% ------------------------------------------------------------------------ |
---|
5335 | filename=regexprep(filename,'.nc',''); |
---|
5336 | % if test_interp==0 |
---|
5337 | if isunix |
---|
5338 | cmd=[Param.xml.PatchBin... |
---|
5339 | ' -f ' filename '.nc -m ' num2str(Param.(patchname).Nx)... |
---|
5340 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
5341 | ' -nopt ' num2str(Param.(patchname).SubdomainSize) ... |
---|
5342 | ' > ' filename '.' lower(patchname) '.log 2>&1']; % redirect standard output to the log file |
---|
5343 | else |
---|
5344 | cmd=['"' Param.xml.PatchBin... |
---|
5345 | '" -f "' filename '.nc" -m ' num2str(Param.(patchname).Nx)... |
---|
5346 | ' -n ' num2str(Param.(patchname).Ny) ' -ro ' num2str(Param.(patchname).SmoothingParam)... |
---|
5347 | ' -nopt ' num2str(Param.(patchname).SubdomainSize)... |
---|
5348 | ' > "' filename '.' lower(patchname) '.log" 2>&1']; % redirect standard output to the log file |
---|
5349 | cmd=regexprep(cmd,'\\','\\\\'); |
---|
5350 | end |
---|
5351 | % else %nouveau programme patch |
---|
5352 | % cmd=[PatchBin ' -f ' filename_nc ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ... |
---|
5353 | % ' -max ' thresh_value ' -nopt ' subdomain_patch ' > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
5354 | % end |
---|
5355 | |
---|
5356 | |
---|
5357 | %------------------------------------------------------------------------ |
---|
5358 | % --- CheckCiv2 CheckCiv2 CheckCiv2 CheckCiv2 |
---|
5359 | function cmd=cmd_civ2(filename,Param) |
---|
5360 | %------------------------------------------------------------------------ |
---|
5361 | %pixels per cm and matrix of the image times, read from the .civ file by uvmat |
---|
5362 | % global civ2Bin sge%name of the executable for checkciv1 calculation |
---|
5363 | filename=regexprep(filename,'.nc',''); |
---|
5364 | if isequal(Param.Civ2.Dt,'0') |
---|
5365 | Param.Civ2.Dt='1' ;%case of 'displacement' mode |
---|
5366 | end |
---|
5367 | Param.Civ2.filename_ima_a=regexprep(Param.Civ2.filename_ima_a,'.png',''); |
---|
5368 | Param.Civ2.filename_ima_b=regexprep(Param.Civ2.filename_ima_b,'.png','');% bug : .png appears two times ? |
---|
5369 | [fid,errormsg]=fopen([filename '.civ2.cmx'],'w'); |
---|
5370 | if isequal(fid,-1) |
---|
5371 | msgbox_uvmat('ERROR',errormsg) |
---|
5372 | cmd=''; |
---|
5373 | return |
---|
5374 | end |
---|
5375 | fprintf(fid,['############## CMX file' '\n' ]); |
---|
5376 | fprintf(fid, ['FirstImage ' regexprep(Param.Civ2.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
5377 | fprintf(fid, ['LastImage ' regexprep(Param.Civ2.filename_ima_b,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
5378 | fprintf(fid, ['XX' '\n' ]); |
---|
5379 | fprintf(fid, ['Mask ' Param.Civ2.MaskFlag '\n' ]); |
---|
5380 | fprintf(fid, ['MaskName ' regexprep(Param.Civ2.MaskName,'\\','\\\\') '\n' ]);% for windows compatibility |
---|
5381 | fprintf(fid, ['ImageSize ' num2str(Param.Civ2.npx) ' ' num2str(Param.Civ2.npy) '\n' ]); %VERIFIER CAS GENERAL ? |
---|
5382 | fprintf(fid, ['CorrelationBoxesSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n' ]); |
---|
5383 | fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']); |
---|
5384 | fprintf(fid, ['RO ' num2str(Param.Civ2.Rho) '\n']); |
---|
5385 | fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); |
---|
5386 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
5387 | fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.T0) '\n' ]); |
---|
5388 | fprintf(fid, ['PixCmXY ' num2str(Param.Civ2.pxcmx) ' ' num2str(Param.Civ2.pxcmy) '\n' ]); |
---|
5389 | fprintf(fid, ['XX 1' '\n' ]); |
---|
5390 | fprintf(fid, 'ShiftXY 0 0\n'); |
---|
5391 | fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); |
---|
5392 | fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); |
---|
5393 | fprintf(fid, ['XX 85' '\n' ]); |
---|
5394 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
5395 | fprintf(fid, ['XX 1.0' '\n' ]); |
---|
5396 | fprintf(fid, ['Hart 1' '\n' ]); |
---|
5397 | fprintf(fid, ['DecimalShift ' num2str(Param.Civ2.CheckDecimal) '\n']); |
---|
5398 | fprintf(fid, ['Deformation ' num2str(Param.Civ2.CheckDeformation) '\n']); |
---|
5399 | fprintf(fid, ['CorrelationMin 0' '\n' ]); |
---|
5400 | fprintf(fid, ['IntensityMin 0' '\n' ]); |
---|
5401 | fprintf(fid, ['SeuilImage n' '\n' ]); |
---|
5402 | fprintf(fid, ['SeuilImageValues 0 4096' '\n' ]); |
---|
5403 | fprintf(fid, ['ImageToUse ' Param.Civ2.term_a ' ' Param.Civ2.term_b '\n' ]); % VERIFIER ? |
---|
5404 | fprintf(fid, ['ImageUsedBefore ' regexprep(Param.Civ2.filename_nc1,'\\','\\\\') '\n']); |
---|
5405 | fclose(fid); |
---|
5406 | |
---|
5407 | if(isunix) |
---|
5408 | cmd=['cp -f ' filename '.civ2.cmx ' filename '.cmx\n'... |
---|
5409 | Param.xml.Civ2Bin ' -f ' filename '.cmx >' filename '.civ2.log \n '... % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx |
---|
5410 | 'rm ' filename '.cmx \n'];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx |
---|
5411 | else |
---|
5412 | filename=regexprep(filename,'\\','\\\\'); |
---|
5413 | cmd=['copy /Y "' filename '.civ2.cmx" "' filename '.cmx" \n'... |
---|
5414 | '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' filename '.cmx" >"' filename '.civ2.log" \n'... |
---|
5415 | 'del "' filename '.cmx" \n']; |
---|
5416 | end |
---|