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