1 | %'civ_input': function associated with the GUI 'civ_input.fig' to set the input parameters for civ_series |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function ParamOut = civ_input(Param) |
---|
4 | % |
---|
5 | % OUPUT: |
---|
6 | % ParamOut: Matlab structure containing the parameters set by the GUI civ_input |
---|
7 | % |
---|
8 | % INPUT: |
---|
9 | % Param: Matlab structure containing the input parameters set by the GUI |
---|
10 | |
---|
11 | %======================================================================= |
---|
12 | % Copyright 2008-2022, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
13 | % http://www.legi.grenoble-inp.fr |
---|
14 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
15 | % |
---|
16 | % This file is part of the toolbox UVMAT. |
---|
17 | % |
---|
18 | % UVMAT is free software; you can redistribute it and/or modify |
---|
19 | % it under the terms of the GNU General Public License as published |
---|
20 | % by the Free Software Foundation; either version 2 of the license, |
---|
21 | % or (at your option) any later version. |
---|
22 | % |
---|
23 | % UVMAT is distributed in the hope that it will be useful, |
---|
24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
26 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
27 | %======================================================================= |
---|
28 | |
---|
29 | function varargout = civ_input(varargin) |
---|
30 | |
---|
31 | gui_Singleton = 1; |
---|
32 | gui_State = struct('gui_Name', mfilename, ... |
---|
33 | 'gui_Singleton', gui_Singleton, ... |
---|
34 | 'gui_OpeningFcn', @civ_input_OpeningFcn, ... |
---|
35 | 'gui_OutputFcn', @civ_input_OutputFcn, ... |
---|
36 | 'gui_LayoutFcn', [] , ... |
---|
37 | 'gui_Callback', []); |
---|
38 | |
---|
39 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback$','once')) |
---|
40 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
41 | end |
---|
42 | |
---|
43 | if nargout |
---|
44 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
45 | else |
---|
46 | gui_mainfcn(gui_State, varargin{:}); |
---|
47 | end |
---|
48 | |
---|
49 | % End initialization code - DO NOT EDIT |
---|
50 | |
---|
51 | %------------------------------------------------------------------------ |
---|
52 | % --- Executes just before civ_input is made visible. |
---|
53 | function civ_input_OpeningFcn(hObject, eventdata, handles, Param) |
---|
54 | %------------------------------------------------------------------------ |
---|
55 | % This function has no output args, see OutputFcn. |
---|
56 | |
---|
57 | %% General settings |
---|
58 | handles.output = Param; |
---|
59 | guidata(hObject, handles); % Update handles structure |
---|
60 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
61 | set(hObject,'WindowKeyPressFcn',{@keyboard_callback,handles})%set keyboard action function |
---|
62 | set(handles.ref_i,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function |
---|
63 | set(handles.ref_j,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function |
---|
64 | hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' |
---|
65 | hhseries=guidata(hseries); %handles of the elements in 'series' |
---|
66 | SeriesData=get(hseries,'UserData');% info stored in the GUI series |
---|
67 | |
---|
68 | %% set visibility options depending on the calling function (Param.Action.ActionName): |
---|
69 | if strcmp(Param.Action.ActionName,'civ_series')||strcmp(Param.Action.ActionName,'stereo_civ') |
---|
70 | set(handles.num_MaxDiff,'Visible','on') |
---|
71 | set(handles.num_MaxVel,'Visible','on') |
---|
72 | set(handles.title_MaxVel,'Visible','on') |
---|
73 | set(handles.title_MaxDiff,'Visible','on') |
---|
74 | set(handles.num_Nx,'Visible','off') |
---|
75 | set(handles.num_Ny,'Visible','off') |
---|
76 | set(handles.title_Nx,'Visible','off') |
---|
77 | set(handles.title_Ny,'Visible','off') |
---|
78 | set(handles.num_CorrSmooth,'Style','popupmenu') |
---|
79 | set(handles.num_CorrSmooth,'Value',1) |
---|
80 | set(handles.num_CorrSmooth,'String',{'1';'2'}) |
---|
81 | set(handles.CheckThreshold,'Visible','on') |
---|
82 | set(handles.CheckDeformation,'Value',0)% desactivate |
---|
83 | end |
---|
84 | switch Param.Action.ActionName |
---|
85 | case 'stereo_civ' |
---|
86 | set(handles.ListCompareMode,'Visible','off') |
---|
87 | set(handles.PairIndices,'Visible','off') |
---|
88 | case 'civ_series' |
---|
89 | set(handles.ListCompareMode,'Visible','on') |
---|
90 | set(handles.PairIndices,'Visible','on') |
---|
91 | end |
---|
92 | |
---|
93 | %% input file info |
---|
94 | NomTypeInput=Param.InputTable{1,4}; |
---|
95 | FileType='image';%fdefault |
---|
96 | FileInfo=[]; |
---|
97 | if isfield(SeriesData,'FileInfo')... |
---|
98 | FileType=SeriesData.FileInfo{1}.FileType;% info on the first input file series |
---|
99 | FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series |
---|
100 | else |
---|
101 | set(hhseries.REFRESH,'BackgroundColor',[1 0 1])% indicate that the file input in series needs to be refreshed |
---|
102 | end |
---|
103 | |
---|
104 | %% case of netcdf file as input, read the processing stage and look for corresponding images |
---|
105 | ind_opening=0;%default |
---|
106 | NomTypeNc=''; |
---|
107 | NomTypeImaA=NomTypeInput; |
---|
108 | iview_image=1;%line # for the input images |
---|
109 | switch FileType |
---|
110 | case 'civdata' |
---|
111 | if ~strcmp(Param.Action.ActionName,'civ_series') |
---|
112 | msgbox_uvmat('ERROR','bad input data file: open an image or a nc file from civ_series') |
---|
113 | return |
---|
114 | end |
---|
115 | NomTypeNc=NomTypeInput; |
---|
116 | ind_opening=FileInfo.CivStage; |
---|
117 | if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) |
---|
118 | set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs |
---|
119 | else |
---|
120 | set(handles.ListCompareMode,'Value',1) |
---|
121 | end |
---|
122 | [Data,tild,tild,errormsg]=nc2struct(FileInfo.FileName,[]); |
---|
123 | if ~isempty(errormsg) |
---|
124 | msgbox_uvmat('ERROR',['error in netcdf input file: ' errormsg]) |
---|
125 | return |
---|
126 | end |
---|
127 | if isfield(Data,'.Civ1_ImageA') |
---|
128 | [PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);%look for the source image A |
---|
129 | [PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);%look for the source image B |
---|
130 | end |
---|
131 | if isfield(Data,'Civ2_ImageA') |
---|
132 | [PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA); |
---|
133 | [PathCiv2_ImageB,Civ2_ImageB,FileExtA]=fileparts(Data.Civ2_ImageB); |
---|
134 | end |
---|
135 | if size(Param.InputTable,1)==1 |
---|
136 | if isfield(Data,'.Civ1_ImageA') |
---|
137 | series('display_file_name',hhseries,Data.Civ1_ImageA,'append');%append the image series to the input list |
---|
138 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA); |
---|
139 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB); |
---|
140 | else |
---|
141 | series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list |
---|
142 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA); |
---|
143 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ2_ImageB); |
---|
144 | end |
---|
145 | end |
---|
146 | |
---|
147 | iview_image=2;%line # for the input images |
---|
148 | case 'civxdata'% case of civx data, |
---|
149 | msgbox_uvmat('ERROR','old civX convention, use the GUI civ') |
---|
150 | return |
---|
151 | otherwise |
---|
152 | if ~strcmp(FieldType,'image') |
---|
153 | msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input') |
---|
154 | return |
---|
155 | end |
---|
156 | end |
---|
157 | |
---|
158 | %% reinitialise menus |
---|
159 | set(handles.ListPairMode,'Value',1) |
---|
160 | set(handles.ListPairMode,'String',{''}) |
---|
161 | set(handles.ListPairCiv1,'Value',1) |
---|
162 | set(handles.ListPairCiv1,'String',{''}) |
---|
163 | set(handles.ListPairCiv2,'Value',1) |
---|
164 | set(handles.ListPairCiv2,'String',{''}) |
---|
165 | |
---|
166 | %% prepare the GUI with input parameters |
---|
167 | % |
---|
168 | set(handles.ref_i,'String',num2str(Param.IndexRange.first_i)) |
---|
169 | if isfield(Param.IndexRange,'first_j') |
---|
170 | set(handles.ref_j,'String',num2str(Param.IndexRange.first_j)) |
---|
171 | end |
---|
172 | set(handles.ConfigSource,'String','\default') |
---|
173 | |
---|
174 | %% set the menus of image pairs and default selection for civ_input %%%%%%%%%%%%%%%%%%% |
---|
175 | |
---|
176 | %% display the min and max indices for the whole file series |
---|
177 | if isempty(Param.IndexRange.MaxIndex_i)|| isempty(Param.IndexRange.MinIndex_i) |
---|
178 | msgbox_uvmat('ERROR','REFRESH the input files in the GUI series') |
---|
179 | return |
---|
180 | end |
---|
181 | MaxIndex_i=Param.IndexRange.MaxIndex_i(iview_image); |
---|
182 | MinIndex_i=Param.IndexRange.MinIndex_i(iview_image); |
---|
183 | MaxIndex_j=1;%default |
---|
184 | MinIndex_j=1; |
---|
185 | if isfield(Param.IndexRange,'MaxIndex_j')&&isfield(Param.IndexRange,'MinIndex_j')... |
---|
186 | && numel(Param.IndexRange.MaxIndex_j')>=iview_image &&numel(Param.IndexRange.MinIndex_j')>=iview_image |
---|
187 | MaxIndex_j=Param.IndexRange.MaxIndex_j(iview_image); |
---|
188 | MinIndex_j=Param.IndexRange.MinIndex_j(iview_image); |
---|
189 | end |
---|
190 | %update the bounds if possible |
---|
191 | if isfield(SeriesData,'i1_series')&&numel(SeriesData.i1_series)>=iview_image |
---|
192 | if size(SeriesData.i1_series{iview_image},2)==2 && min(min(SeriesData.i1_series{iview_image}(:,1,:)))==0 |
---|
193 | MinIndex_j=1;% index j set to 1 by default |
---|
194 | MaxIndex_j=1; |
---|
195 | MinIndex_i=find(SeriesData.i1_series{iview_image}(1,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) |
---|
196 | MaxIndex_i=find(SeriesData.i1_series{iview_image}(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series) |
---|
197 | else |
---|
198 | ref_i=squeeze(max(SeriesData.i1_series{iview_image}(1,:,:),[],2));% select ref_j index for each ref_i |
---|
199 | ref_j=squeeze(max(SeriesData.j1_series{iview_image}(1,:,:),[],3));% select ref_i index for each ref_j |
---|
200 | MinIndex_i=min(find(ref_i))-1; |
---|
201 | MaxIndex_i=max(find(ref_i))-1; |
---|
202 | MaxIndex_j=max(find(ref_j))-1; |
---|
203 | MinIndex_j=min(find(ref_j))-1; |
---|
204 | end |
---|
205 | end |
---|
206 | |
---|
207 | |
---|
208 | %% transfer the time from the GUI series, or use file index by default |
---|
209 | time=[]; |
---|
210 | TimeUnit='frame'; %default |
---|
211 | CoordUnit='';%default |
---|
212 | pxcm_search=1; |
---|
213 | if isfield(SeriesData,'Time') &&numel(SeriesData.Time')>=1 && ~isempty(SeriesData.Time{1}) |
---|
214 | time=SeriesData.Time{1}; |
---|
215 | end |
---|
216 | if isfield(Param.IndexRange,'TimeUnit')&&~isempty(Param.IndexRange.TimeUnit) |
---|
217 | TimeUnit=Param.IndexRange.TimeUnit; |
---|
218 | end |
---|
219 | if isfield(SeriesData,'GeometryCalib') |
---|
220 | tsai=SeriesData.GeometryCalib; |
---|
221 | if isfield(tsai,'fx_fy') |
---|
222 | pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range |
---|
223 | end |
---|
224 | if isfield(tsai,'CoordUnit') |
---|
225 | CoordUnit=tsai.CoordUnit; |
---|
226 | end |
---|
227 | end |
---|
228 | |
---|
229 | %% timing display |
---|
230 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
231 | if numel(time)>=2 % if there are at least two time values to define dt |
---|
232 | if size(time,1)<MaxIndex_i; |
---|
233 | msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file'); |
---|
234 | elseif size(time,2)<MaxIndex_j |
---|
235 | msgbox_uvmat('WARNING','maximum j index restricted by the timing of the xml file'); |
---|
236 | end |
---|
237 | MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data |
---|
238 | MaxIndex_j=min(size(time,2),MaxIndex_j); |
---|
239 | set(handles.TimeSource,'String',Param.IndexRange.TimeSource); |
---|
240 | else |
---|
241 | set(handles.TimeSource,'String',''); %xml file not used for timing |
---|
242 | TimeUnit='frame'; |
---|
243 | time=ones(MaxIndex_j-MinIndex_j+1,1)*(MinIndex_i:MaxIndex_i); |
---|
244 | time=time+0.001*(MinIndex_j:MaxIndex_j)'*ones(1,MaxIndex_i-MinIndex_i+1); |
---|
245 | end |
---|
246 | CivInputData.Time=time; |
---|
247 | CivInputData.NomTypeIma=NomTypeImaA; |
---|
248 | set(handles.civ_input,'UserData',CivInputData) |
---|
249 | set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) |
---|
250 | set(handles.TimeUnit,'String',TimeUnit); |
---|
251 | set(handles.SearchRange,'UserData', pxcm_search); |
---|
252 | |
---|
253 | |
---|
254 | %% set the civ_input options, depending on the input file content if a nc file has been opened |
---|
255 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
256 | checkbox=zeros(size(ListOptions));%default |
---|
257 | checkrefresh=0; |
---|
258 | if ind_opening==0 %case of image opening, start with Civ1 |
---|
259 | for index=1:numel(ListOptions) |
---|
260 | checkbox(index)=get(handles.(ListOptions{index}),'Value'); |
---|
261 | end |
---|
262 | index_max=find(checkbox, 1, 'last' ); |
---|
263 | if isempty(index_max),index_max=1;end |
---|
264 | for index=1:index_max |
---|
265 | set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1 |
---|
266 | end |
---|
267 | else %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed |
---|
268 | if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&... |
---|
269 | ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) |
---|
270 | for index = 1:min(ind_opening,5) |
---|
271 | set(handles.(ListOptions{index}),'value',0) |
---|
272 | fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file |
---|
273 | end |
---|
274 | set(handles.ConfigSource,'String',FileInfo.FileName); |
---|
275 | set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) |
---|
276 | for index = ind_opening+2:6 |
---|
277 | set(handles.(ListOptions{index}),'value',0) |
---|
278 | end |
---|
279 | checkrefresh=1; |
---|
280 | end |
---|
281 | if ind_opening>=3 |
---|
282 | set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2. |
---|
283 | else |
---|
284 | set(handles.CheckCiv3,'Visible','off') |
---|
285 | end |
---|
286 | end |
---|
287 | |
---|
288 | %% introduce the stored Civ parameters if available (from previous input or ImportConfig in series) |
---|
289 | if ~checkrefresh && isfield(Param,'ActionInput')&& strcmp(Param.ActionInput.Program,Param.Action.ActionName)% the program fits with the stored data |
---|
290 | fill_GUI(Param.ActionInput,hObject);%fill the GUI with the parameters retrieved from the input Param |
---|
291 | hcheckgrid=findobj(handles.civ_input,'Tag','CheckGrid'); |
---|
292 | for ilist=1:numel(hcheckgrid) |
---|
293 | if get(hcheckgrid(ilist),'Value')% if a grid is used, do not show Dx and Dy for an automatic grid |
---|
294 | hparent=get(hcheckgrid(ilist),'parent');%handles of the parent panel |
---|
295 | hchildren=get(hparent,'children'); |
---|
296 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
297 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
298 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
299 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
300 | set(handle_dx,'Visible','off'); |
---|
301 | set(handle_dy,'Visible','off'); |
---|
302 | set(handle_title_dy,'Visible','off'); |
---|
303 | set(handle_title_dx,'Visible','off'); |
---|
304 | end |
---|
305 | end |
---|
306 | if isfield(Param.ActionInput,'Civ2') |
---|
307 | CheckDeformation_Callback(hObject, eventdata, handles) |
---|
308 | end |
---|
309 | end |
---|
310 | if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ListCompareMode')&&... |
---|
311 | strcmp(Param.ActionInput.ListCompareMode,'displacement') |
---|
312 | set(handles.PairIndices,'Visible','off') |
---|
313 | set(handles.CheckRefFile,'Visible','on') |
---|
314 | else |
---|
315 | set(handles.CheckRefFile,'Visible','off') |
---|
316 | end |
---|
317 | |
---|
318 | %% set the menu and default choice of civ pairs |
---|
319 | if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs |
---|
320 | PairMenu={'series(Di)'}; |
---|
321 | elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j |
---|
322 | PairMenu={'pair j1-j2';'series(Dj)'}; |
---|
323 | else |
---|
324 | PairMenu={'pair j1-j2';'series(Dj)';'series(Di)'};%multiple choice |
---|
325 | end |
---|
326 | set(handles.ListPairMode,'String',PairMenu) |
---|
327 | |
---|
328 | %% set default choice of pair mode |
---|
329 | PairIndex=[]; |
---|
330 | if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'PairIndices') |
---|
331 | PairIndex=find(strcmp(Param.ActionInput.PairIndices.ListPairMode,PairMenu));%retrieve the previous option |
---|
332 | end |
---|
333 | if isempty(PairIndex) |
---|
334 | if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs |
---|
335 | PairIndex=1; |
---|
336 | elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j |
---|
337 | if MaxIndex_j <= 10 |
---|
338 | PairIndex=1;% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
339 | end |
---|
340 | else |
---|
341 | if strcmp(NomTypeNc,'_1-2_1') |
---|
342 | PairIndex=3;% advise 'series(Di)' |
---|
343 | elseif MaxIndex_j <= 10 |
---|
344 | PairIndex=1;% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
345 | else |
---|
346 | PairIndex=2;% advice 'Dj' |
---|
347 | end |
---|
348 | end |
---|
349 | end |
---|
350 | set(handles.ListPairMode,'Value',PairIndex); |
---|
351 | |
---|
352 | %% indicate the min and max indices i and j on the GUI |
---|
353 | set(handles.MinIndex_i,'String',num2str(MinIndex_i)) |
---|
354 | set(handles.MaxIndex_i,'String',num2str(MaxIndex_i)) |
---|
355 | set(handles.MinIndex_j,'String',num2str(MinIndex_j)) |
---|
356 | set(handles.MaxIndex_j,'String',num2str(MaxIndex_j)) |
---|
357 | |
---|
358 | %% set the reference indices from the input file indices |
---|
359 | if ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) |
---|
360 | update_CivOptions(handles,ind_opening)% fill the menu of possible pairs |
---|
361 | end |
---|
362 | |
---|
363 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
364 | ListPairMode_Callback([], [], handles) |
---|
365 | |
---|
366 | %% set the GUI to modal: wait for OK to close |
---|
367 | set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal |
---|
368 | drawnow |
---|
369 | uiwait(handles.civ_input);% wait for OK action to end the function |
---|
370 | |
---|
371 | |
---|
372 | %------------------------------------------------------------------------ |
---|
373 | % --- Outputs from this function are returned to the command line. |
---|
374 | function varargout = civ_input_OutputFcn(hObject, eventdata, handles) |
---|
375 | %------------------------------------------------------------------------ |
---|
376 | % Get default command line output from handles structure |
---|
377 | varargout{1}=[];% default output when civ_input is canceled (no 'OK') |
---|
378 | if ~isempty(handles) |
---|
379 | varargout{1} = handles.output; |
---|
380 | delete(handles.civ_input) |
---|
381 | end |
---|
382 | |
---|
383 | % --- Executes when user attempts to close get_field. |
---|
384 | function civ_input_CloseRequestFcn(hObject, eventdata, handles) |
---|
385 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
386 | % The GUI is still in UIWAIT, us UIRESUME |
---|
387 | uiresume(handles.civ_input); |
---|
388 | else |
---|
389 | % The GUI is no longer waiting, just close it |
---|
390 | delete(handles.civ_input); |
---|
391 | end |
---|
392 | |
---|
393 | %------------------------------------------------------------------------ |
---|
394 | % --- Executes on button press in SetDefaultParam. |
---|
395 | %------------------------------------------------------------------------ |
---|
396 | function SetDefaultParam_Callback(hObject, eventdata, handles) |
---|
397 | |
---|
398 | Param.ConfigSource='\default'; |
---|
399 | |
---|
400 | %% Civ1 parameters |
---|
401 | %Param.CheckCiv1=1; |
---|
402 | Param.Civ1.CorrBoxSize=[25 25]; |
---|
403 | Param.Civ1.SearchBoxSize=[55 55]; |
---|
404 | Param.Civ1.SearchBoxShift=[0 0]; |
---|
405 | Param.Civ1.CorrSmooth=1; |
---|
406 | Param.Civ1.Dx=20; |
---|
407 | Param.Civ1.Dy=20; |
---|
408 | Param.Civ1.CheckGrid=0; |
---|
409 | Param.Civ1.CheckMask=0; |
---|
410 | Param.Civ1.Mask=''; |
---|
411 | Param.Civ1.CheckThreshold=0; |
---|
412 | Param.Civ1.TestCiv1=0; |
---|
413 | |
---|
414 | %% Fix1 parameters |
---|
415 | %Param.CheckFix1=1; |
---|
416 | Param.Fix1.CheckFmin2=1; |
---|
417 | Param.Fix1.CheckF3=1; |
---|
418 | Param.Fix1.MinCorr=0.2000; |
---|
419 | |
---|
420 | %% Patch1 parameters |
---|
421 | %Param.CheckPatch1=1; |
---|
422 | Param.Patch1.FieldSmooth=10; |
---|
423 | Param.Patch1.MaxDiff=1.5000; |
---|
424 | Param.Patch1.SubDomainSize=1000; |
---|
425 | Param.Patch1.TestPatch1=0; |
---|
426 | |
---|
427 | %% Civ2 parameters |
---|
428 | %Param.CheckCiv2=1; |
---|
429 | Param.Civ2.CorrBoxSize=[21 21]; |
---|
430 | Param.Civ2.SearchBoxSize=[27 27]; |
---|
431 | Param.Civ2.CorrSmooth=1; |
---|
432 | Param.Civ2.Dx=10; |
---|
433 | Param.Civ2.Dy=10; |
---|
434 | Param.Civ2.CheckGrid=0; |
---|
435 | Param.Civ2.CheckMask=0; |
---|
436 | Param.Civ2.Mask=''; |
---|
437 | Param.Civ2.CheckThreshold=0; |
---|
438 | Param.Civ2.TestCiv2=0; |
---|
439 | |
---|
440 | %% Fix2 parameters |
---|
441 | %Param.CheckFix2=1; |
---|
442 | Param.Fix2.CheckFmin2=1; |
---|
443 | Param.Fix2.CheckF4=1; |
---|
444 | Param.Fix2.CheckF3=1; |
---|
445 | Param.Fix2.MinCorr=0.2000; |
---|
446 | |
---|
447 | %% Patch2 parameters |
---|
448 | %Param.CheckPatch2=1; |
---|
449 | Param.Patch2.FieldSmooth=2; |
---|
450 | Param.Patch2.MaxDiff=1.5000; |
---|
451 | Param.Patch2.SubDomainSize=1000; |
---|
452 | Param.Patch2.TestPatch2=0; |
---|
453 | |
---|
454 | fill_GUI(Param,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
455 | update_CivOptions(handles,0) |
---|
456 | |
---|
457 | % ----------------------------------------------------------------------- |
---|
458 | % ----------------------------------------------------------------------- |
---|
459 | % --- Open the help html file |
---|
460 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
461 | % ----------------------------------------------------------------------- |
---|
462 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#Civ') |
---|
463 | |
---|
464 | %------------------------------------------------------------------------ |
---|
465 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
466 | function Civ1_ImageB_Callback(hObject, eventdata, handles) |
---|
467 | %------------------------------------------------------------------------ |
---|
468 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
469 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
470 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
471 | if isempty(ichoice) |
---|
472 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
473 | else |
---|
474 | ilist=ichoice; |
---|
475 | end |
---|
476 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
477 | if get(handles.CheckCiv1,'Value')% if Civ1 is performed |
---|
478 | set(handles.Civ2_ImageA,'String',SubDir);% set by default civ2 directory the same as civ1 |
---|
479 | % set(handles.ListSubdirCiv2,'Value',ilist) |
---|
480 | else % if Civ1 data already exist |
---|
481 | errormsg=find_netcpair_civ(handles,1); %update the list of available index pairs in the new directory |
---|
482 | if ~isempty(errormsg) |
---|
483 | msgbox_uvmat('ERROR',errormsg) |
---|
484 | end |
---|
485 | end |
---|
486 | |
---|
487 | %------------------------------------------------------------------------ |
---|
488 | % --- Executes on carriage return on the SubDir checkciv1 edit window |
---|
489 | function Civ2_ImageA_Callback(hObject, eventdata, handles) |
---|
490 | %------------------------------------------------------------------------ |
---|
491 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
492 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
493 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
494 | if isempty(ichoice) |
---|
495 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
496 | else |
---|
497 | ilist=ichoice; |
---|
498 | end |
---|
499 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
500 | %update the list of available pairs from netcdf files in the new directory |
---|
501 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
502 | errormsg=find_netcpair_civ(handles,2); |
---|
503 | if ~isempty(errormsg) |
---|
504 | msgbox_uvmat('ERROR',errormsg) |
---|
505 | end |
---|
506 | end |
---|
507 | |
---|
508 | %------------------------------------------------------------------------ |
---|
509 | % --- Executes on button press in CheckCiv1. |
---|
510 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
511 | %------------------------------------------------------------------------ |
---|
512 | update_CivOptions(handles,0) |
---|
513 | |
---|
514 | %------------------------------------------------------------------------ |
---|
515 | % --- Executes on button press in CheckFix1. |
---|
516 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
517 | %------------------------------------------------------------------------ |
---|
518 | update_CivOptions(handles,0) |
---|
519 | |
---|
520 | %------------------------------------------------------------------------ |
---|
521 | % --- Executes on button press in CheckPatch1. |
---|
522 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
523 | %------------------------------------------------------------------------ |
---|
524 | update_CivOptions(handles,0) |
---|
525 | |
---|
526 | %------------------------------------------------------------------------ |
---|
527 | % --- Executes on button press in CheckCiv2. |
---|
528 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
529 | %------------------------------------------------------------------------ |
---|
530 | update_CivOptions(handles,0) |
---|
531 | |
---|
532 | %------------------------------------------------------------------------ |
---|
533 | % --- Executes on button press in CheckFix2. |
---|
534 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
535 | %------------------------------------------------------------------------ |
---|
536 | update_CivOptions(handles,0) |
---|
537 | |
---|
538 | %------------------------------------------------------------------------ |
---|
539 | % --- Executes on button press in CheckPatch2. |
---|
540 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
541 | %------------------------------------------------------------------------ |
---|
542 | update_CivOptions(handles,0) |
---|
543 | |
---|
544 | %------------------------------------------------------------------------ |
---|
545 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
546 | function update_CivOptions(handles,opening) |
---|
547 | %------------------------------------------------------------------------ |
---|
548 | if opening>0 |
---|
549 | set(handles.CheckCiv2,'UserData',opening)% store the info on the current status of the civ processing |
---|
550 | end |
---|
551 | checkbox=zeros(1,6); |
---|
552 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
553 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
554 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
555 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
556 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
557 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
558 | if opening==0 |
---|
559 | errormsg=find_netcpair_civ(handles,1); % select the available netcdf files |
---|
560 | if ~isempty(errormsg) |
---|
561 | msgbox_uvmat('ERROR',errormsg) |
---|
562 | end |
---|
563 | end |
---|
564 | if max(checkbox(4:6))>0% case of civ2 pair choice needed |
---|
565 | set(handles.TitlePairCiv2,'Visible','on') |
---|
566 | set(handles.ListPairCiv2,'Visible','on') |
---|
567 | if ~opening |
---|
568 | errormsg=find_netcpair_civ(handles,2); % select the available netcdf files |
---|
569 | if ~isempty(errormsg) |
---|
570 | msgbox_uvmat('ERROR',errormsg) |
---|
571 | end |
---|
572 | end |
---|
573 | else |
---|
574 | set(handles.ListPairCiv2,'Visible','off') |
---|
575 | end |
---|
576 | hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' |
---|
577 | hhseries=guidata(hseries); %handles of the elements in 'series' |
---|
578 | InputTable=get(hhseries.InputTable,'Data'); |
---|
579 | if size(InputTable,1)>=1 && strcmp(InputTable{1,5},'.nc') && max(checkbox(1:3))==0 %&& get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 |
---|
580 | set(handles.CheckCiv3,'Visible','on') |
---|
581 | else |
---|
582 | set(handles.CheckCiv3,'Visible','off') |
---|
583 | end |
---|
584 | |
---|
585 | %% set the visibility of the different panels |
---|
586 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
587 | for ilist=1:length(options) |
---|
588 | if checkbox(ilist) |
---|
589 | set(handles.(options{ilist}),'Visible','on') |
---|
590 | else |
---|
591 | set(handles.(options{ilist}),'Visible','off') |
---|
592 | end |
---|
593 | end |
---|
594 | |
---|
595 | %------------------------------------------------------------------------ |
---|
596 | % --- Executes on button press in OK: processing on local computer |
---|
597 | function OK_Callback(hObject, eventdata, handles) |
---|
598 | %------------------------------------------------------------------------ |
---|
599 | |
---|
600 | ActionInput=read_GUI(handles.civ_input);% read the infos on the GUI civ_input |
---|
601 | |
---|
602 | %% correct input inconsistencies |
---|
603 | if isfield(ActionInput,'Civ1') |
---|
604 | checkeven=(mod(ActionInput.Civ1.CorrBoxSize,2)==0); |
---|
605 | ActionInput.Civ1.CorrBoxSize(checkeven)=ActionInput.Civ1.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
606 | ActionInput.Civ1.SearchBoxSize=max(ActionInput.Civ1.SearchBoxSize,ActionInput.Civ1.CorrBoxSize+8);% insure that the search box size is large enough |
---|
607 | checkeven=(mod(ActionInput.Civ1.SearchBoxSize,2)==0); |
---|
608 | ActionInput.Civ1.SearchBoxSize(checkeven)=ActionInput.Civ1.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
609 | end |
---|
610 | if isfield(ActionInput,'Civ2') |
---|
611 | checkeven=(mod(ActionInput.Civ2.CorrBoxSize,2)==0); |
---|
612 | ActionInput.Civ2.CorrBoxSize(checkeven)=ActionInput.Civ2.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
613 | ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+4); |
---|
614 | checkeven=(mod(ActionInput.Civ2.SearchBoxSize,2)==0); |
---|
615 | ActionInput.Civ2.SearchBoxSize(checkeven)=ActionInput.Civ2.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
616 | end |
---|
617 | |
---|
618 | %% correct mask or grid name for Windows system (replace '\' by '/') |
---|
619 | if isfield(ActionInput,'Civ1') |
---|
620 | if isfield(ActionInput.Civ1,'Mask') |
---|
621 | ActionInput.Civ1.Mask=regexprep(ActionInput.Civ1.Mask,'\','/'); |
---|
622 | end |
---|
623 | if isfield(ActionInput.Civ1,'Grid') |
---|
624 | ActionInput.Civ1.Grid=regexprep(ActionInput.Civ1.Grid,'\','/'); |
---|
625 | end |
---|
626 | end |
---|
627 | if isfield(ActionInput,'Civ2') |
---|
628 | if isfield(ActionInput.Civ2,'Mask') |
---|
629 | ActionInput.Civ2.Mask=regexprep(ActionInput.Civ2.Mask,'\','/'); |
---|
630 | end |
---|
631 | if isfield(ActionInput.Civ2,'Grid') |
---|
632 | ActionInput.Civ2.Grid=regexprep(ActionInput.Civ2.Grid,'\','/'); |
---|
633 | end |
---|
634 | end |
---|
635 | |
---|
636 | %% exit the GUI and close it |
---|
637 | handles.output.ActionInput=ActionInput; |
---|
638 | guidata(hObject, handles);% Update handles structure |
---|
639 | uiresume(handles.civ_input); |
---|
640 | |
---|
641 | |
---|
642 | %------------------------------------------------------------------------ |
---|
643 | % --- Executes on button press in ListCompareMode. |
---|
644 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
645 | %------------------------------------------------------------------------ |
---|
646 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
647 | option=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
648 | hseries=findobj(allchild(0),'Tag','series'); |
---|
649 | SeriesData=get(hseries,'UserData'); |
---|
650 | check_nc=strcmp(SeriesData.FileType{1},'.nc'); |
---|
651 | ImageType=SeriesData.FileType(2:end); |
---|
652 | if check_nc |
---|
653 | ImageType=SeriesData.FileType(2:end); |
---|
654 | else |
---|
655 | ImageType=SeriesData.FileType; |
---|
656 | end |
---|
657 | hhseries=guidata(hseries); |
---|
658 | InputTable=get(hhseries.InputTable,'Data'); |
---|
659 | OriginIndex='off'; |
---|
660 | PairIndices='off'; |
---|
661 | switch option |
---|
662 | case 'PIV' |
---|
663 | PairIndices='on';% needs to define index pairs for PIV |
---|
664 | case 'PIV volume' |
---|
665 | PairIndices='on';% needs to define index pairs for PIV |
---|
666 | set(handles.ListPairMode,'Value',1) |
---|
667 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
668 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
669 | case 'displacement' |
---|
670 | OriginIndex='on';%define a frame origin for displacement |
---|
671 | end |
---|
672 | set(handles.num_OriginIndex,'Visible',OriginIndex) |
---|
673 | set(handles.OriginIndex_title,'Visible',OriginIndex) |
---|
674 | set(handles.CheckRefFile,'Visible',OriginIndex) |
---|
675 | set(handles.RefFile,'Visible',OriginIndex) |
---|
676 | set(handles.PairIndices,'Visible',PairIndices) |
---|
677 | ListPairMode_Callback(hObject,eventdata,handles) |
---|
678 | if strcmp(OriginIndex,'on') |
---|
679 | set(handles.CheckRefFile,'Value',1) |
---|
680 | CheckRefFile_Callback(hObject,eventdata,handles) |
---|
681 | end |
---|
682 | |
---|
683 | |
---|
684 | |
---|
685 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
686 | % Callbacks in the uipanel Pair Indices |
---|
687 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
688 | %------------------------------------------------------------------------ |
---|
689 | % --- Executes on button press in ListPairMode. |
---|
690 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
691 | %------------------------------------------------------------------------ |
---|
692 | compare_list=get(handles.ListCompareMode,'String'); |
---|
693 | val=get(handles.ListCompareMode,'Value'); |
---|
694 | compare=compare_list{val}; |
---|
695 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
696 | mode_selected='displacement'; |
---|
697 | else |
---|
698 | mode_list=get(handles.ListPairMode,'String'); |
---|
699 | if ischar(mode_list) |
---|
700 | mode_list={mode_list}; |
---|
701 | end |
---|
702 | mode_value=get(handles.ListPairMode,'Value'); |
---|
703 | if isempty(mode_value) |
---|
704 | mode_value=1; |
---|
705 | end |
---|
706 | mode_selected=mode_list{mode_value}; |
---|
707 | end |
---|
708 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
709 | CivInputData=get(handles.civ_input,'UserData'); |
---|
710 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
711 | checkframe=strcmp(TimeUnit,'frame'); |
---|
712 | time=CivInputData.Time; |
---|
713 | siztime=size(CivInputData.Time); |
---|
714 | nbfield=siztime(1)-1; |
---|
715 | nbfield2=siztime(2)-1; |
---|
716 | %indchosen=1; %%first pair selected by default |
---|
717 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
718 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
719 | if isequal(mode_selected,'pair j1-j2') |
---|
720 | dt=1; |
---|
721 | index=0; |
---|
722 | numlist_a=[]; |
---|
723 | numlist_B=[]; |
---|
724 | %get all the time intervals in bursts |
---|
725 | displ_dt=1;%default |
---|
726 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
727 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
728 | for numod_b=(numod_a+1):nbfield2 |
---|
729 | index=index+1; |
---|
730 | numlist_a(index)=numod_a; |
---|
731 | numlist_b(index)=numod_b; |
---|
732 | if size(time,2)>1 && ~checkframe && size(CivInputData.Time,1)>ref_i && size(CivInputData.Time,2)>numod_b |
---|
733 | dt(numod_a,numod_b)=CivInputData.Time(ref_i+1,numod_b+1)-CivInputData.Time(ref_i+1,numod_a+1);%first time interval dt |
---|
734 | displ_dt(index)=dt(numod_a,numod_b); |
---|
735 | else |
---|
736 | displ_dt(index)=1; |
---|
737 | end |
---|
738 | end |
---|
739 | end |
---|
740 | [dtsort,indsort]=sort(displ_dt); |
---|
741 | enable_j(handles, 'off') |
---|
742 | elseif isequal(mode_selected,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
743 | enable_j(handles, 'on') |
---|
744 | elseif isequal(mode_selected,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
745 | enable_i(handles, 'on') |
---|
746 | if nbfield2 > 1 |
---|
747 | enable_j(handles, 'on') |
---|
748 | else |
---|
749 | enable_j(handles, 'off') |
---|
750 | end |
---|
751 | elseif isequal(mode_selected,'displacement')%the pairs have the same indices |
---|
752 | if nbfield > 1 || nbfield==0 |
---|
753 | enable_i(handles, 'on') |
---|
754 | else |
---|
755 | enable_j(handles, 'off') |
---|
756 | end |
---|
757 | if nbfield2 > 1 |
---|
758 | enable_j(handles, 'on') |
---|
759 | else |
---|
760 | enable_j(handles, 'off') |
---|
761 | end |
---|
762 | end |
---|
763 | errormsg=find_netcpair_civ( handles,1); |
---|
764 | if ~isempty(errormsg) |
---|
765 | msgbox_uvmat('ERROR',errormsg) |
---|
766 | end |
---|
767 | |
---|
768 | %------------------------------------------------------------------------ |
---|
769 | function enable_i(handles, state) |
---|
770 | set(handles.itext,'Visible',state) |
---|
771 | set(handles.MaxIndex_i,'Visible',state) |
---|
772 | set(handles.ref_i,'Visible',state) |
---|
773 | |
---|
774 | %------------------------------------------------------------------------ |
---|
775 | function enable_j(handles, state) |
---|
776 | set(handles.jtext,'Visible',state) |
---|
777 | set(handles.MinIndex_j,'Visible',state) |
---|
778 | set(handles.MaxIndex_j,'Visible',state) |
---|
779 | set(handles.ref_j,'Visible',state) |
---|
780 | |
---|
781 | %------------------------------------------------------------------------ |
---|
782 | % --- Executes on selection change in ListPairCiv1. |
---|
783 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
784 | %------------------------------------------------------------------------ |
---|
785 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
786 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
787 | PairString=list_pair{get(handles.ListPairCiv1,'Value')}; |
---|
788 | |
---|
789 | [ind1,ind2]=... |
---|
790 | find_pair_indices(PairString); |
---|
791 | hseries=findobj(allchild(0),'Tag','series'); |
---|
792 | hhseries=guidata(hseries); |
---|
793 | set(hhseries.num_first_j,'String',num2str(ind1)); |
---|
794 | set(hhseries.num_last_j,'String',num2str(ind2)); |
---|
795 | set(hhseries.num_incr_j,'String',num2str(ind2-ind1)); |
---|
796 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ& by default |
---|
797 | |
---|
798 | |
---|
799 | %------------------------------------------------------------------------ |
---|
800 | % --- Executes on selection change in ListPairCiv2. |
---|
801 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
802 | %------------------------------------------------------------------------ |
---|
803 | |
---|
804 | |
---|
805 | %------------------------------------------------------------------------ |
---|
806 | function ref_i_Callback(hObject, eventdata, handles) |
---|
807 | %------------------------------------------------------------------------ |
---|
808 | mode_list=get(handles.ListPairMode,'String'); |
---|
809 | mode_value=get(handles.ListPairMode,'Value'); |
---|
810 | mode_selected=mode_list{mode_value}; |
---|
811 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
812 | if isequal(mode_selected,'series(Di)') || ...% we do patch2 only |
---|
813 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
814 | errormsg=find_netcpair_civ( handles,2); |
---|
815 | end |
---|
816 | if isempty(errormsg) |
---|
817 | set(handles.ref_i,'BackgroundColor',[1 1 1]) |
---|
818 | set(handles.ref_j,'BackgroundColor',[1 1 1]) |
---|
819 | else |
---|
820 | msgbox_uvmat('ERROR',errormsg) |
---|
821 | end |
---|
822 | |
---|
823 | function ref_i_KeyPressFcn(hObject, eventdata, handles) |
---|
824 | set(hObject,'BackgroundColor',[1 0 1]) |
---|
825 | |
---|
826 | % %------------------------------------------------------------------------ |
---|
827 | |
---|
828 | function errormsg=find_netcpair_civ(handles,index) |
---|
829 | %------------------------------------------------------------------------ |
---|
830 | set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock) |
---|
831 | |
---|
832 | %% initialisation |
---|
833 | errormsg=''; |
---|
834 | CivInputData=get(handles.civ_input,'UserData'); |
---|
835 | compare_list=get(handles.ListCompareMode,'String'); |
---|
836 | val=get(handles.ListCompareMode,'Value'); |
---|
837 | compare=compare_list{val}; |
---|
838 | mode_selected='displacement'; |
---|
839 | if ~strcmp(compare,'displacement')%||strcmp(compare,'shift') |
---|
840 | |
---|
841 | mode_list=get(handles.ListPairMode,'String'); |
---|
842 | mode_value=get(handles.ListPairMode,'Value'); |
---|
843 | if isempty(mode_value) |
---|
844 | mode_value=1; |
---|
845 | end |
---|
846 | if isempty(mode_list) |
---|
847 | return |
---|
848 | end |
---|
849 | mode_selected=mode_list{mode_value}; |
---|
850 | end |
---|
851 | nom_type_ima=CivInputData.NomTypeIma; |
---|
852 | menu_pair=get(handles.ListPairCiv1,'String');%previous menu of ListPairCiv1 |
---|
853 | PairCiv1Init=menu_pair{get(handles.ListPairCiv1,'Value')};%previous choice of pair |
---|
854 | menu_pair=get(handles.ListPairCiv2,'String');%previous menu of ListPairCiv1 |
---|
855 | PairCiv2Init=menu_pair{get(handles.ListPairCiv2,'Value')};%previous choice of pair |
---|
856 | |
---|
857 | %% reads .nc subdirectoy and image numbers from the interface |
---|
858 | %SubDirImages=get(handles.Civ1_ImageA,'String'); |
---|
859 | %TODO: determine |
---|
860 | %subdir_civ1=[SubDirImages get(handles.Civ1_ImageB,'String')];%subdirectory subdir_civ1 for the netcdf data |
---|
861 | %subdir_civ2=[SubDirImages get(handles.Civ2_ImageA,'String')];%subdirectory subdir_civ2 for the netcdf data |
---|
862 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
863 | ref_j=[]; |
---|
864 | if isequal(mode_selected,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
865 | ref_j=0; |
---|
866 | elseif strcmp(get(handles.ref_j,'Visible'),'on') |
---|
867 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
868 | end |
---|
869 | if isempty(ref_j) |
---|
870 | ref_j=1; |
---|
871 | end |
---|
872 | CivInputData=get(handles.civ_input,'UserData'); |
---|
873 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
874 | Time=CivInputData.Time; |
---|
875 | checkframe=strcmp(TimeUnit,'frame'); |
---|
876 | |
---|
877 | %% case with no Civ1 operation, netcdf files need to exist for reading |
---|
878 | displ_pair={''}; |
---|
879 | nbpair=200;%default |
---|
880 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
881 | |
---|
882 | %% determine the menu display in .ListPairCiv1 |
---|
883 | switch mode_selected |
---|
884 | case 'series(Di)' |
---|
885 | for ipair=1:nbpair |
---|
886 | if select(ipair) |
---|
887 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
888 | displ_pair_dt{ipair}=displ_pair{ipair}; |
---|
889 | if ~checkframe |
---|
890 | if size(Time,1)>=ref_i+1+ceil(ipair/2) && size(Time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0 |
---|
891 | 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 |
---|
892 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
893 | end |
---|
894 | else |
---|
895 | dt=ipair/1000; |
---|
896 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(ipair)]; |
---|
897 | end |
---|
898 | else |
---|
899 | displ_pair{ipair}='...'; |
---|
900 | displ_pair_dt{ipair}='...'; %pair not displayed in the menu |
---|
901 | end |
---|
902 | end |
---|
903 | case 'series(Dj)' |
---|
904 | for ipair=1:nbpair |
---|
905 | if select(ipair) |
---|
906 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
907 | displ_pair_dt{ipair}=displ_pair{ipair}; |
---|
908 | if ~checkframe |
---|
909 | if size(Time,2)>=ref_j+1+ceil(ipair/2) && size(Time,1)>=ref_i+1 && ref_j-floor(ipair/2)>=0 && ref_i>=0 |
---|
910 | dt=Time(ref_i+1,ref_j+1+ceil(ipair/2))-Time(ref_i+1,ref_j+1-floor(ipair/2));%Time interval dtref_j+1 |
---|
911 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
912 | end |
---|
913 | else |
---|
914 | dt=ipair/1000; |
---|
915 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
916 | end |
---|
917 | else |
---|
918 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
919 | displ_pair_dt{ipair}='...'; %pair not displayed in the menu |
---|
920 | end |
---|
921 | end |
---|
922 | case 'pair j1-j2'%case of pairs |
---|
923 | MinIndex_j=str2num(get(handles.MinIndex_j,'String')); |
---|
924 | MaxIndex_j=str2num(get(handles.MaxIndex_j,'String')); |
---|
925 | index_pair=0; |
---|
926 | %get all the Time intervals in bursts |
---|
927 | displ_pair_dt=''; |
---|
928 | for numod_a=MinIndex_j:MaxIndex_j-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
929 | for numod_b=(numod_a+1):MaxIndex_j |
---|
930 | index_pair=index_pair+1; |
---|
931 | displ_pair{index_pair}=['j= ' num2stra(numod_a,nom_type_ima) '-' num2stra(numod_b,nom_type_ima)]; |
---|
932 | displ_pair_dt{index_pair}=displ_pair{index_pair}; |
---|
933 | dt(index_pair)=numod_b-numod_a;%default dt |
---|
934 | if size(Time,1)>ref_i && size(Time,2)>numod_b % && ~checkframe |
---|
935 | dt(index_pair)=Time(ref_i+1,numod_b+1)-Time(ref_i+1,numod_a+1);% Time interval dt |
---|
936 | displ_pair_dt{index_pair}=[displ_pair_dt{index_pair} ' :dt= ' num2str(dt(index_pair)*1000)]; |
---|
937 | end |
---|
938 | end |
---|
939 | |
---|
940 | end |
---|
941 | if index_pair ~=0 |
---|
942 | [tild,indsort]=sort(dt); |
---|
943 | displ_pair=displ_pair(indsort); |
---|
944 | displ_pair_dt=displ_pair_dt(indsort); |
---|
945 | end |
---|
946 | case 'displacement' |
---|
947 | % displ_pair={'Di=Dj=0'}; |
---|
948 | % displ_pair_dt={'Di=Dj=0'}; |
---|
949 | set(handles.PairIndices,'Visible','off') |
---|
950 | end |
---|
951 | if index==1 && ~strcmp(mode_selected,'displacement') |
---|
952 | set(handles.ListPairCiv1,'String',displ_pair_dt'); |
---|
953 | end |
---|
954 | |
---|
955 | %% determine the default selection in the pair menu for Civ1 |
---|
956 | %ichoice=find(select,1);% index of first selected pair |
---|
957 | %if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
958 | end_pair=regexp(PairCiv1Init,' :dt='); |
---|
959 | if ~isempty(end_pair) |
---|
960 | PairCiv1Init=PairCiv1Init(1:end_pair-1); |
---|
961 | end |
---|
962 | ichoice=find(strcmp(PairCiv1Init,displ_pair'),1); |
---|
963 | if ~isempty(ichoice) |
---|
964 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
965 | else |
---|
966 | set(handles.ListPairCiv1,'Value',1) |
---|
967 | end |
---|
968 | |
---|
969 | %% determine the default selection in the pair menu for Civ2 |
---|
970 | if ~strcmp(mode_selected,'displacement') |
---|
971 | if strcmp(get(handles.ListPairCiv2,'Visible'),'on') |
---|
972 | end_pair=regexp(PairCiv2Init,' :dt='); |
---|
973 | if ~isempty(end_pair) |
---|
974 | PairCiv2Init=PairCiv2Init(1:end_pair-1); |
---|
975 | end |
---|
976 | ichoice=find(strcmp(PairCiv2Init,displ_pair'),1); |
---|
977 | if ~isempty(ichoice) |
---|
978 | set(handles.ListPairCiv2,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
979 | else |
---|
980 | set(handles.ListPairCiv2,'Value',1) |
---|
981 | end |
---|
982 | else |
---|
983 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))% initiate the choice of Civ2 as a reproduction of if civ1 |
---|
984 | end |
---|
985 | set(handles.ListPairCiv2,'String',displ_pair_dt'); |
---|
986 | end |
---|
987 | set(gcf,'Pointer','arrow')% Indicate that the process is finished |
---|
988 | |
---|
989 | |
---|
990 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
991 | % Callbacks in the uipanel Reference Indices |
---|
992 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
993 | %------------------------------------------------------------------------ |
---|
994 | function MinIndex_i_Callback(hObject, eventdata, handles) |
---|
995 | %------------------------------------------------------------------------ |
---|
996 | first_i=str2double(get(handles.MinIndex_i,'String')); |
---|
997 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
998 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
999 | |
---|
1000 | % %------------------------------------------------------------------------ |
---|
1001 | % function MinIndex_j_Callback(hObject, eventdata, handles) |
---|
1002 | % %------------------------------------------------------------------------ |
---|
1003 | % first_j=str2num(get(handles.MinIndex_j,'String')); |
---|
1004 | % set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
1005 | % ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
1006 | |
---|
1007 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1008 | % Callbacks in the uipanel Civ1 |
---|
1009 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1010 | %------------------------------------------------------------------------ |
---|
1011 | % --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 |
---|
1012 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
1013 | %------------------------------------------------------------------------ |
---|
1014 | %determine pair numbers |
---|
1015 | if strcmp(get(handles.num_UMin,'Visible'),'off') |
---|
1016 | set(handles.u_title,'Visible','on') |
---|
1017 | set(handles.v_title,'Visible','on') |
---|
1018 | set(handles.num_UMin,'Visible','on') |
---|
1019 | set(handles.num_UMax,'Visible','on') |
---|
1020 | set(handles.num_VMin,'Visible','on') |
---|
1021 | set(handles.num_VMax,'Visible','on') |
---|
1022 | %set(handles.CoordUnit,'Visible','on') |
---|
1023 | %set(handles.TimeUnit,'Visible','on') |
---|
1024 | %set(handles.slash_title,'Visible','on') |
---|
1025 | set(handles.min_title,'Visible','on') |
---|
1026 | set(handles.max_title,'Visible','on') |
---|
1027 | set(handles.unit_title,'Visible','on') |
---|
1028 | else |
---|
1029 | get_search_range(hObject, eventdata, handles) |
---|
1030 | end |
---|
1031 | |
---|
1032 | %------------------------------------------------------------------------ |
---|
1033 | % --- determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift |
---|
1034 | function get_search_range(hObject, eventdata, handles) |
---|
1035 | %------------------------------------------------------------------------ |
---|
1036 | param_civ1=read_GUI(handles.Civ1); |
---|
1037 | umin=param_civ1.UMin; |
---|
1038 | umax=param_civ1.UMax; |
---|
1039 | vmin=param_civ1.VMin; |
---|
1040 | vmax=param_civ1.VMax; |
---|
1041 | %switch min_title and max_title in case of error |
---|
1042 | if umax<=umin |
---|
1043 | umin_old=umin; |
---|
1044 | umin=umax; |
---|
1045 | umax=umin_old; |
---|
1046 | set(handles.num_UMin,'String', num2str(umin)) |
---|
1047 | set(handles.num_UMax,'String', num2str(umax)) |
---|
1048 | end |
---|
1049 | if vmax<=vmin |
---|
1050 | vmin_old=vmin; |
---|
1051 | vmin=vmax; |
---|
1052 | vmax=vmin_old; |
---|
1053 | set(handles.num_VMin,'String', num2str(vmin)) |
---|
1054 | set(handles.num_VMax,'String', num2str(vmax)) |
---|
1055 | end |
---|
1056 | if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax)) |
---|
1057 | shiftx=round((umin+umax)/2); |
---|
1058 | shifty=round((vmin+vmax)/2); |
---|
1059 | isx=(umax+2-shiftx)*2+param_civ1.CorrBoxSize(1); |
---|
1060 | isx=2*ceil(isx/2)+1; |
---|
1061 | isy=(vmax+2-shifty)*2+param_civ1.CorrBoxSize(2); |
---|
1062 | isy=2*ceil(isy/2)+1; |
---|
1063 | set(handles.num_SearchBoxShift_1,'String',num2str(shiftx)); |
---|
1064 | set(handles.num_SearchBoxShift_2,'String',num2str(shifty)); |
---|
1065 | set(handles.num_SearchBoxSize_1,'String',num2str(isx)); |
---|
1066 | set(handles.num_SearchBoxSize_2,'String',num2str(isy)); |
---|
1067 | end |
---|
1068 | |
---|
1069 | %------------------------------------------------------------------------ |
---|
1070 | % --- Executes on selection in menu CorrSmooth. |
---|
1071 | function num_CorrSmooth_Callback(hObject, eventdata, handles) |
---|
1072 | set(handles.ConfigSource,'String','NEW') |
---|
1073 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1074 | %------------------------------------------------------------------------ |
---|
1075 | |
---|
1076 | % --- Executes on button press in CheckDeformation. |
---|
1077 | function CheckDeformation_Callback(hObject, eventdata, handles) |
---|
1078 | set(handles.ConfigSource,'String','NEW') |
---|
1079 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1080 | handles_CoorSmooth=findobj(get(handles.Civ2,'children'),'Tag','num_CorrSmooth'); |
---|
1081 | if get(handles.CheckDeformation,'Value') |
---|
1082 | set(handles_CoorSmooth,'Visible','off') |
---|
1083 | else |
---|
1084 | set(handles_CoorSmooth,'Visible','on') |
---|
1085 | end |
---|
1086 | |
---|
1087 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1088 | % Callbacks in the uipanel Fix1 |
---|
1089 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1090 | %------------------------------------------------------------------------ |
---|
1091 | % % --- Executes on button press in CheckMask. |
---|
1092 | % function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
1093 | % %------------------------------------------------------------------------ |
---|
1094 | % maskval=get(handles.CheckMask,'Value'); |
---|
1095 | % if isequal(maskval,0) |
---|
1096 | % set(handles.Mask,'String','') |
---|
1097 | % else |
---|
1098 | % mask_displ='no mask'; %default |
---|
1099 | % filebase=get(handles.RootPath,'String'); |
---|
1100 | % [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1101 | % if isequal(flag_mask,1) |
---|
1102 | % mask_displ=[num2str(nbslice) 'mask']; |
---|
1103 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1104 | % filebase_a=get(handles.RootFile_1,'String'); |
---|
1105 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1106 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1107 | % mask_displ='no mask'; |
---|
1108 | % end |
---|
1109 | % end |
---|
1110 | % if isequal(mask_displ,'no mask') |
---|
1111 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1112 | % {'*.png', ' (*.png)'; |
---|
1113 | % '*.png', '.png files '; ... |
---|
1114 | % '*.*', 'All Files (*.*)'}, ... |
---|
1115 | % 'Pick a mask file *.png',filebase); |
---|
1116 | % mask_displ=fullfile(PathName,FileName); |
---|
1117 | % if ~exist(mask_displ,'file') |
---|
1118 | % mask_displ='no mask'; |
---|
1119 | % end |
---|
1120 | % end |
---|
1121 | % if isequal(mask_displ,'no mask') |
---|
1122 | % set(handles.CheckMask,'Value',0) |
---|
1123 | % set(handles.CheckMask,'Value',0) |
---|
1124 | % set(handles.CheckMask,'Value',0) |
---|
1125 | % else |
---|
1126 | % %set(handles.CheckMask,'Value',1) |
---|
1127 | % set(handles.CheckMask,'Value',1) |
---|
1128 | % end |
---|
1129 | % set(handles.Mask,'String',mask_displ) |
---|
1130 | % set(handles.Mask,'String',mask_displ) |
---|
1131 | % set(handles.Mask,'String',mask_displ) |
---|
1132 | % end |
---|
1133 | |
---|
1134 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1135 | % Callbacks in the uipanel Civ2 |
---|
1136 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1137 | %------------------------------------------------------------------------ |
---|
1138 | % --- Executes on button press in CheckMask: select box for mask option |
---|
1139 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
1140 | %------------------------------------------------------------------------ |
---|
1141 | maskval=get(handles.CheckMask,'Value'); |
---|
1142 | if isequal(maskval,0) |
---|
1143 | set(handles.Mask,'String','') |
---|
1144 | else |
---|
1145 | mask_displ='no mask'; %default |
---|
1146 | filebase=get(handles.RootPath,'String'); |
---|
1147 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1148 | if isequal(flag_mask,1) |
---|
1149 | mask_displ=[num2str(nbslice) 'mask']; |
---|
1150 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1151 | filebase_a=get(handles.RootFile_1,'String'); |
---|
1152 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1153 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1154 | mask_displ='no mask'; |
---|
1155 | end |
---|
1156 | end |
---|
1157 | if isequal(mask_displ,'no mask') |
---|
1158 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1159 | {'*.png', ' (*.png)'; |
---|
1160 | '*.png', '.png files '; ... |
---|
1161 | '*.*', 'All Files (*.*)'}, ... |
---|
1162 | 'Pick a mask file *.png',filebase); |
---|
1163 | mask_displ=fullfile(PathName,FileName); |
---|
1164 | if ~exist(mask_displ,'file') |
---|
1165 | mask_displ='no mask'; |
---|
1166 | end |
---|
1167 | end |
---|
1168 | if isequal(mask_displ,'no mask') |
---|
1169 | set(handles.CheckMask,'Value',0) |
---|
1170 | set(handles.CheckMask,'Value',0) |
---|
1171 | else |
---|
1172 | set(handles.CheckMask,'Value',1) |
---|
1173 | end |
---|
1174 | set(handles.Mask,'String',mask_displ) |
---|
1175 | end |
---|
1176 | |
---|
1177 | % %------------------------------------------------------------------------ |
---|
1178 | % % --- Executes on button press in CheckMask. |
---|
1179 | % function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
1180 | % %------------------------------------------------------------------------ |
---|
1181 | % maskval=get(handles.CheckMask,'Value'); |
---|
1182 | % if isequal(maskval,0) |
---|
1183 | % set(handles.Mask,'String','') |
---|
1184 | % else |
---|
1185 | % mask_displ='no mask'; %default |
---|
1186 | % filebase=get(handles.RootPath,'String'); |
---|
1187 | % [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1188 | % if isequal(flag_mask,1) |
---|
1189 | % mask_displ=[num2str(nbslice) 'mask']; |
---|
1190 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1191 | % filebase_a=get(handles.RootFile_1,'String'); |
---|
1192 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1193 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1194 | % mask_displ='no mask'; |
---|
1195 | % end |
---|
1196 | % end |
---|
1197 | % if isequal(mask_displ,'no mask') |
---|
1198 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1199 | % {'*.png', ' (*.png)'; |
---|
1200 | % '*.png', '.png files '; ... |
---|
1201 | % '*.*', 'All Files (*.*)'}, ... |
---|
1202 | % 'Pick a mask file *.png',filebase); |
---|
1203 | % mask_displ=fullfile(PathName,FileName); |
---|
1204 | % if ~exist(mask_displ,'file') |
---|
1205 | % mask_displ='no mask'; |
---|
1206 | % end |
---|
1207 | % end |
---|
1208 | % if isequal(mask_displ,'no mask') |
---|
1209 | % set(handles.CheckMask,'Value',0) |
---|
1210 | % end |
---|
1211 | % set(handles.Mask,'String',mask_displ) |
---|
1212 | % end |
---|
1213 | |
---|
1214 | %------------------------------------------------------------------------ |
---|
1215 | % --- function called to look for mask files |
---|
1216 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
1217 | %------------------------------------------------------------------------ |
---|
1218 | %detect mask files, images with appropriate file base |
---|
1219 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
1220 | %flag_mask=1 indicates detection |
---|
1221 | |
---|
1222 | flag_mask=0;%default |
---|
1223 | nbslice=1; |
---|
1224 | |
---|
1225 | % subdir=get(handles.Civ1_ImageB,'String'); |
---|
1226 | [Path,Name]=fileparts(filebase); |
---|
1227 | if ~isdir(Path) |
---|
1228 | msgbox_uvmat('ERROR','no path for input files') |
---|
1229 | return |
---|
1230 | end |
---|
1231 | % currentdir=pwd; |
---|
1232 | % cd(Path);%move in the dir of the root name filebase |
---|
1233 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
1234 | % cd(currentdir);%come back to the current working directory |
---|
1235 | if ~isempty(maskfiles) |
---|
1236 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
1237 | % else |
---|
1238 | flag_mask=1; |
---|
1239 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
1240 | [Path2,Name,ext]=fileparts(maskname); |
---|
1241 | Namedouble=double(Name); |
---|
1242 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1243 | ind_mask=findstr('mask',Name); |
---|
1244 | i=ind_mask-1; |
---|
1245 | while val(i)==0 && i>0 |
---|
1246 | i=i-1; |
---|
1247 | end |
---|
1248 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
1249 | if ~isnan(nbslice) && Name(i)=='_' |
---|
1250 | flag_mask=1; |
---|
1251 | else |
---|
1252 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
1253 | return |
---|
1254 | nbslice=1; |
---|
1255 | end |
---|
1256 | end |
---|
1257 | |
---|
1258 | %------------------------------------------------------------------------ |
---|
1259 | % --- function called to look for grid files |
---|
1260 | function [nbslice, flag_grid]=get_grid(filebase,handles) |
---|
1261 | %------------------------------------------------------------------------ |
---|
1262 | flag_grid=0;%default |
---|
1263 | nbslice=1; |
---|
1264 | [Path,Name]=fileparts(filebase); |
---|
1265 | currentdir=pwd; |
---|
1266 | cd(Path);%move in the dir of the root name filebase |
---|
1267 | gridfiles=dir([Name '_*grid_*.grid']);%look for grid files |
---|
1268 | cd(currentdir);%come back to the current working directory |
---|
1269 | if ~isempty(gridfiles) |
---|
1270 | flag_grid=1; |
---|
1271 | gridname=gridfiles(1).name;% take the first grid file in the list |
---|
1272 | [Path2,Name,ext]=fileparts(gridname); |
---|
1273 | Namedouble=double(Name); |
---|
1274 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1275 | ind_grid=findstr('grid',Name); |
---|
1276 | i=ind_grid-1; |
---|
1277 | while val(i)==0 && i>0 |
---|
1278 | i=i-1; |
---|
1279 | end |
---|
1280 | nbslice=str2double(Name(i+1:ind_grid-1)); |
---|
1281 | if ~isnan(nbslice) && Name(i)=='_' |
---|
1282 | flag_grid=1; |
---|
1283 | else |
---|
1284 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
1285 | return |
---|
1286 | nbslice=1; |
---|
1287 | end |
---|
1288 | end |
---|
1289 | |
---|
1290 | %------------------------------------------------------------------------ |
---|
1291 | % --- transform numbers to letters |
---|
1292 | function str=num2stra(num,nom_type) |
---|
1293 | %------------------------------------------------------------------------ |
---|
1294 | if isempty(nom_type) |
---|
1295 | str=''; |
---|
1296 | elseif strcmp(nom_type(end),'a') |
---|
1297 | str=char(96+num); |
---|
1298 | elseif strcmp(nom_type(end),'A') |
---|
1299 | str=char(96+num); |
---|
1300 | elseif isempty(nom_type(2:end))%a single index |
---|
1301 | str=''; |
---|
1302 | else |
---|
1303 | str=num2str(num); |
---|
1304 | end |
---|
1305 | |
---|
1306 | % %------------------------------------------------------------------------ |
---|
1307 | % % --- Executes on button press in ListSubdirCiv1. |
---|
1308 | % function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
1309 | % %------------------------------------------------------------------------ |
---|
1310 | % list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
1311 | % val=get(handles.ListSubdirCiv1,'Value'); |
---|
1312 | % SubDir=list_subdir_civ1{val}; |
---|
1313 | % if strcmp(SubDir,'new...') |
---|
1314 | % if get(handles.CheckCiv1,'Value') |
---|
1315 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
1316 | % else |
---|
1317 | % msgbox_uvmat('ERROR','select CheckCiv1 to perform a new civ_input operation') |
---|
1318 | % return |
---|
1319 | % end |
---|
1320 | % end |
---|
1321 | % set(handles.Civ1_ImageB,'String',SubDir); |
---|
1322 | % errormsg=find_netcpair_civ(handles,1); |
---|
1323 | % if ~isempty(errormsg) |
---|
1324 | % msgbox_uvmat('ERROR',errormsg) |
---|
1325 | % end |
---|
1326 | % |
---|
1327 | %------------------------------------------------------------------------ |
---|
1328 | % % --- Executes on button press in ListSubdirCiv2. |
---|
1329 | % function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
1330 | % %------------------------------------------------------------------------ |
---|
1331 | % list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
1332 | % val=get(handles.ListSubdirCiv2,'Value'); |
---|
1333 | % SubDir=list_subdir_civ2{val}; |
---|
1334 | % if strcmp(SubDir,'new...') |
---|
1335 | % if get(handles.CheckCiv2,'Value') |
---|
1336 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
1337 | % else |
---|
1338 | % msgbox_uvmat('ERROR','select CheckCiv2 to perform a new civ_input operation') |
---|
1339 | % return |
---|
1340 | % end |
---|
1341 | % end |
---|
1342 | % set(handles.Civ2_ImageA,'String',SubDir); |
---|
1343 | |
---|
1344 | %------------------------------------------------------------------------ |
---|
1345 | % --- Executes on button press in CheckGrid. |
---|
1346 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
1347 | %------------------------------------------------------------------------ |
---|
1348 | value=get(hObject,'Value'); |
---|
1349 | hparent=get(hObject,'parent');%handles of the parent panel |
---|
1350 | hchildren=get(hparent,'children'); |
---|
1351 | handle_txtbox=findobj(hchildren,'tag','Grid');% look for the grid name box in the same panel |
---|
1352 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
1353 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
1354 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
1355 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
1356 | testgrid=0; |
---|
1357 | filegrid=''; |
---|
1358 | if value |
---|
1359 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1360 | hhseries=guidata(hseries); |
---|
1361 | InputTable=get(hhseries.InputTable,'Data'); |
---|
1362 | ind_A=1;% line index of the (first) image series |
---|
1363 | if strcmp(InputTable{1,5},'.nc'); |
---|
1364 | ind_A=2; |
---|
1365 | end |
---|
1366 | filebase=InputTable{ind_A,1}; |
---|
1367 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
1368 | if isequal(flag_grid,1) |
---|
1369 | filegrid=[num2str(nbslice) 'grid']; |
---|
1370 | testgrid=1; |
---|
1371 | else % browse for a grid |
---|
1372 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
1373 | if exist(filegrid,'file') |
---|
1374 | filebase=filegrid; |
---|
1375 | end |
---|
1376 | filegrid = uigetfile_uvmat('pick a grid file .grid:',filebase,'.grid'); |
---|
1377 | set(hObject,'UserData',filegrid);%store for future use |
---|
1378 | if ~isempty(filegrid) |
---|
1379 | testgrid=1; |
---|
1380 | end |
---|
1381 | set(hObject,'UserData',filegrid);%store for future use |
---|
1382 | end |
---|
1383 | end |
---|
1384 | if testgrid |
---|
1385 | set(handle_dx,'Visible','off'); |
---|
1386 | set(handle_dy,'Visible','off'); |
---|
1387 | set(handle_title_dy,'Visible','off'); |
---|
1388 | set(handle_title_dx,'Visible','off'); |
---|
1389 | set(handle_txtbox,'Visible','on') |
---|
1390 | set(handle_txtbox,'String',filegrid) |
---|
1391 | else |
---|
1392 | set(hObject,'Value',0); |
---|
1393 | set(handle_dx,'Visible','on'); |
---|
1394 | set(handle_dy,'Visible','on'); |
---|
1395 | set(handle_title_dy,'Visible','on'); |
---|
1396 | set(handle_title_dx,'Visible','on'); |
---|
1397 | set(handle_txtbox,'Visible','off') |
---|
1398 | end |
---|
1399 | |
---|
1400 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
1401 | PanelName=get(hparent,'tag'); |
---|
1402 | if strcmp(PanelName,'Civ1') |
---|
1403 | hchildren=get(handles.Civ2,'children'); |
---|
1404 | handle_checkbox=findobj(hchildren,'tag','CheckGrid'); |
---|
1405 | handle_txtbox=findobj(hchildren,'tag','Grid'); |
---|
1406 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
1407 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
1408 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
1409 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
1410 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
1411 | if testgrid |
---|
1412 | set(handle_checkbox,'Value',1); |
---|
1413 | set(handle_dx,'Visible','off'); |
---|
1414 | set(handle_dy,'Visible','off'); |
---|
1415 | set(handle_title_dx,'Visible','off'); |
---|
1416 | set(handle_title_dy,'Visible','off'); |
---|
1417 | set(handle_txtbox,'Visible','on') |
---|
1418 | set(handle_txtbox,'String',filegrid) |
---|
1419 | end |
---|
1420 | end |
---|
1421 | set(handles.ConfigSource,'String','NEW') |
---|
1422 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1423 | |
---|
1424 | %------------------------------------------------------------------------ |
---|
1425 | % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) |
---|
1426 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1427 | %------------------------------------------------------------------------ |
---|
1428 | value=get(hObject,'Value'); |
---|
1429 | hparent=get(hObject,'parent'); |
---|
1430 | parent_tag=get(hparent,'Tag'); |
---|
1431 | hchildren=get(hparent,'children'); |
---|
1432 | handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel |
---|
1433 | handle_NbSlice=findobj(hchildren,'tag','num_NbSlice');% look for the mask name box in the same panel |
---|
1434 | testmask=0; |
---|
1435 | if value |
---|
1436 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1437 | hhseries=guidata(hseries); |
---|
1438 | InputTable=get(hhseries.InputTable,'Data'); |
---|
1439 | ind_A=1;% line index of the (first) image series |
---|
1440 | if strcmp(InputTable{1,5},'.nc'); |
---|
1441 | ind_A=2; |
---|
1442 | end |
---|
1443 | % browse for a mask |
---|
1444 | filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image'); |
---|
1445 | [FilePath,FileName,Ext]=fileparts(filemask); |
---|
1446 | [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName,Ext]); |
---|
1447 | if strcmp(NomType,'_1') |
---|
1448 | NbSlice=i1_series(1,2,end); |
---|
1449 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
1450 | end |
---|
1451 | set(hObject,'UserData',filemask);%store for future use |
---|
1452 | if ~isempty(filemask) |
---|
1453 | testmask=1; |
---|
1454 | end |
---|
1455 | end |
---|
1456 | if testmask |
---|
1457 | set(handles.Mask,'Visible','on') |
---|
1458 | set(handles.Mask,'String',filemask) |
---|
1459 | set(handles.CheckMask,'Value',1) |
---|
1460 | if strcmp(NomType,'_1') |
---|
1461 | set(handles.num_NbSlice,'Visible','on') |
---|
1462 | end |
---|
1463 | else |
---|
1464 | set(hObject,'Value',0); |
---|
1465 | set(handle_txtbox,'Visible','off') |
---|
1466 | set(handles.num_NbSlice,'Visible','off') |
---|
1467 | end |
---|
1468 | set(handles.ConfigSource,'String','NEW') |
---|
1469 | set(handles.ConfigSource,'BackgroundColor',[1 0 1]) |
---|
1470 | |
---|
1471 | % %------------------------------------------------------------------------ |
---|
1472 | % % --- Executes on button press in get_gridpatch1. |
---|
1473 | % function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
1474 | % %------------------------------------------------------------------------ |
---|
1475 | % filebase=get(handles.RootPath,'String'); |
---|
1476 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1477 | % {'*.grid', ' (*.grid)'; |
---|
1478 | % '*.grid', '.grid files '; ... |
---|
1479 | % '*.*', 'All Files (*.*)'}, ... |
---|
1480 | % 'Pick a file',filebase); |
---|
1481 | % filegrid=fullfile(PathName,FileName); |
---|
1482 | % set(handles.grid_patch1,'string',filegrid); |
---|
1483 | % set(hObject,'BackgroundColor',[1 0 1]) |
---|
1484 | |
---|
1485 | %------------------------------------------------------------------------ |
---|
1486 | % --- STEREO Interp |
---|
1487 | 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) |
---|
1488 | %------------------------------------------------------------------------ |
---|
1489 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
1490 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
1491 | ' -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 |
---|
1492 | |
---|
1493 | % %------------------------------------------------------------------------ |
---|
1494 | % %--read images and convert them to the uint16 format used for PIV |
---|
1495 | % function A=read_image(filename,type_ima,num,movieobject) |
---|
1496 | % %------------------------------------------------------------------------ |
---|
1497 | % %num is the view number needed for an avi movie |
---|
1498 | % switch type_ima |
---|
1499 | % case 'movie' |
---|
1500 | % A=read(movieobject,num); |
---|
1501 | % case 'avi' |
---|
1502 | % mov=aviread(filename,num); |
---|
1503 | % A=frame2im(mov(1)); |
---|
1504 | % case 'multimage' |
---|
1505 | % A=imread(filename,num); |
---|
1506 | % case 'image' |
---|
1507 | % A=imread(filename); |
---|
1508 | % end |
---|
1509 | % siz=size(A); |
---|
1510 | % if length(siz)==3;%color images |
---|
1511 | % A=sum(double(A),3); |
---|
1512 | % A=uint16(A); |
---|
1513 | % end |
---|
1514 | |
---|
1515 | |
---|
1516 | %------------------------------------------------------------------------ |
---|
1517 | % --- Executes on button press in get_ref_fix1. |
---|
1518 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
1519 | %------------------------------------------------------------------------ |
---|
1520 | filebase=get(handles.RootPath,'String'); |
---|
1521 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1522 | {'*.nc', ' (*.nc)'; |
---|
1523 | '*.nc', 'netcdf files '; ... |
---|
1524 | '*.*', 'All Files (*.*)'}, ... |
---|
1525 | 'Pick a file',filebase); |
---|
1526 | |
---|
1527 | fileinput=[PathName FileName]; |
---|
1528 | sizf=size(fileinput); |
---|
1529 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
1530 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
1531 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
1532 | ref.filebase=fullfile(Path,File); |
---|
1533 | % ref.num_a=stra2num(str_a); |
---|
1534 | % ref.num_b=stra2num(str_b); |
---|
1535 | % ref.num1=str2double(field_count); |
---|
1536 | % ref.num2=str2double(str2); |
---|
1537 | browse=[];%initialisation |
---|
1538 | if ~isequal(ref.ext,'.nc') |
---|
1539 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
1540 | return |
---|
1541 | end |
---|
1542 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
1543 | set(handles.ref_fix1,'UserData',ref) |
---|
1544 | menu_field{1}='civ1'; |
---|
1545 | Data=nc2struct(fileinput,[]); |
---|
1546 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
1547 | menu_field{2}='filter1'; |
---|
1548 | end |
---|
1549 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
1550 | menu_field{3}='civ2'; |
---|
1551 | end |
---|
1552 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
1553 | menu_field{4}='filter2'; |
---|
1554 | end |
---|
1555 | set(handles.field_ref1,'String',menu_field); |
---|
1556 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
1557 | set(handles.num_MinVel,'Value',2); |
---|
1558 | set(handles.num_MinVel,'String','1');%default threshold |
---|
1559 | set(handles.ref_fix1,'Enable','on') |
---|
1560 | |
---|
1561 | %------------------------------------------------------------------------ |
---|
1562 | % --- Executes on button press in get_ref_fix2. |
---|
1563 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
1564 | %------------------------------------------------------------------------ |
---|
1565 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
1566 | filebase=get(handles.RootPath,'String'); |
---|
1567 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1568 | {'*.nc', ' (*.nc)'; |
---|
1569 | '*.nc', 'netcdf files '; ... |
---|
1570 | '*.*', 'All Files (*.*)'}, ... |
---|
1571 | 'Pick a file',filebase); |
---|
1572 | fileinput=[PathName FileName]; |
---|
1573 | sizf=size(fileinput); |
---|
1574 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
1575 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
1576 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
1577 | ref.filebase=fullfile(Path,File); |
---|
1578 | % ref.num_a=stra2num(str_a); |
---|
1579 | % ref.num_b=stra2num(str_b); |
---|
1580 | % ref.num1=str2num(field_count); |
---|
1581 | % ref.num2=str2num(str2); |
---|
1582 | browse=[];%initialisation |
---|
1583 | if ~isequal(ref.ext,'.nc') |
---|
1584 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
1585 | return |
---|
1586 | end |
---|
1587 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
1588 | set(handles.ref_fix2,'UserData',ref) |
---|
1589 | menu_field{1}='civ1'; |
---|
1590 | Data=nc2struct(fileinput,[]); |
---|
1591 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
1592 | menu_field{2}='filter1'; |
---|
1593 | end |
---|
1594 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
1595 | menu_field{3}='civ2'; |
---|
1596 | end |
---|
1597 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
1598 | menu_field{4}='filter2'; |
---|
1599 | end |
---|
1600 | set(handles.field_ref2,'String',menu_field); |
---|
1601 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
1602 | set(handles.num_MinVel,'Value',2); |
---|
1603 | set(handles.num_MinVel,'String','1');%default threshold |
---|
1604 | set(handles.ref_fix2,'Enable','on') |
---|
1605 | set(handles.ref_fix2,'Visible','on') |
---|
1606 | set(handles.field_ref2,'Visible','on') |
---|
1607 | else |
---|
1608 | set(handles.ref_fix2,'Visible','off') |
---|
1609 | set(handles.field_ref2,'Visible','off') |
---|
1610 | end |
---|
1611 | |
---|
1612 | %------------------------------------------------------------------------ |
---|
1613 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
1614 | %------------------------------------------------------------------------ |
---|
1615 | set(handles.num_MinVel,'Value',1); |
---|
1616 | set(handles.field_ref1,'Value',1) |
---|
1617 | set(handles.field_ref1,'String',{' '}) |
---|
1618 | set(handles.ref_fix1,'UserData',[]); |
---|
1619 | set(handles.ref_fix1,'String',''); |
---|
1620 | set(handles.thresh_vel1,'String','0'); |
---|
1621 | |
---|
1622 | %------------------------------------------------------------------------ |
---|
1623 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
1624 | %------------------------------------------------------------------------ |
---|
1625 | set(handles.num_MinVel,'Value',1); |
---|
1626 | set(handles.field_ref2,'Value',1) |
---|
1627 | set(handles.field_ref2,'String',{' '}) |
---|
1628 | set(handles.ref_fix2,'UserData',[]); |
---|
1629 | set(handles.ref_fix2,'String',''); |
---|
1630 | set(handles.num_MinVel,'String','0'); |
---|
1631 | |
---|
1632 | %------------------------------------------------------------------------ |
---|
1633 | % --- TO ABANDON Executes on button press in test_stereo1. |
---|
1634 | function CheckStereo_Callback(hObject, eventdata, handles) |
---|
1635 | %------------------------------------------------------------------------ |
---|
1636 | hparent=get(hObject,'parent'); |
---|
1637 | parent_tag=get(hparent,'Tag'); |
---|
1638 | hchildren=get(hparent,'children'); |
---|
1639 | handle_txtbox=findobj(hchildren,'tag','txt_Mask'); |
---|
1640 | if isequal(get(hObject,'Value'),0) |
---|
1641 | set(handles.num_SubDomainSize,'Visible','on') |
---|
1642 | set(handles.num_FieldSmooth,'Visible','on') |
---|
1643 | else |
---|
1644 | set(handles.num_SubDomainSize,'Visible','off') |
---|
1645 | set(handles.num_FieldSmooth,'Visible','off') |
---|
1646 | end |
---|
1647 | |
---|
1648 | % %------------------------------------------------------------------------ |
---|
1649 | % % --- Executes on button press in CheckStereo. |
---|
1650 | % function StereoCheck_Callback(hObject, eventdata, handles) |
---|
1651 | % %------------------------------------------------------------------------ |
---|
1652 | % if isequal(get(handles.CheckStereo,'Value'),0) |
---|
1653 | % set(handles.num_subdomainsize,'Visible','on') |
---|
1654 | % set(handles.num_FieldSmooth,'Visible','on') |
---|
1655 | % else |
---|
1656 | |
---|
1657 | % set(handles.num_subdomainsize,'Visible','off') |
---|
1658 | % set(handles.num_FieldSmooth,'Visible','off') |
---|
1659 | % end |
---|
1660 | |
---|
1661 | |
---|
1662 | |
---|
1663 | %------------------------------------------------------------------------ |
---|
1664 | %----function introduced for the correlation window figure, activated by deleting this window |
---|
1665 | function closeview_field(gcbo,eventdata) |
---|
1666 | %------------------------------------------------------------------------ |
---|
1667 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1668 | if ~isempty(hview_field) |
---|
1669 | delete(hview_field) |
---|
1670 | end |
---|
1671 | |
---|
1672 | %------------------------------------------------------------------------ |
---|
1673 | % --- Executes on button press in CheckThreshold. |
---|
1674 | function CheckThreshold_Callback(hObject, eventdata, handles) |
---|
1675 | %------------------------------------------------------------------------ |
---|
1676 | huipanel=get(hObject,'parent'); |
---|
1677 | obj(1)=findobj(huipanel,'Tag','num_MinIma'); |
---|
1678 | obj(2)=findobj(huipanel,'Tag','num_MaxIma'); |
---|
1679 | obj(3)=findobj(huipanel,'Tag','title_Threshold'); |
---|
1680 | if get(hObject,'Value') |
---|
1681 | set(obj,'Visible','on') |
---|
1682 | else |
---|
1683 | set(obj,'Visible','off') |
---|
1684 | end |
---|
1685 | set(handles.ConfigSource,'String','NEW') |
---|
1686 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1687 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1688 | %%%%%%%%%%%%%% TEST functions |
---|
1689 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1690 | %------------------------------------------------------------------------ |
---|
1691 | % --- Executes on button press in TestCiv1: prepare the image correlation function |
---|
1692 | % activated by mouse motion |
---|
1693 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
1694 | %------------------------------------------------------------------------ |
---|
1695 | drawnow |
---|
1696 | if get(handles.TestCiv1,'Value') |
---|
1697 | set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch |
---|
1698 | set(handles.CheckFix1,'value',0)% desactivate next step |
---|
1699 | set(handles.CheckPatch1,'value',0)% desactivate next step |
---|
1700 | set(handles.CheckCiv2,'value',0)% desactivate next step |
---|
1701 | set(handles.CheckFix2,'value',0)% desactivate next step |
---|
1702 | set(handles.CheckPatch2,'value',0)% desactivate next step |
---|
1703 | update_CivOptions(handles,0) |
---|
1704 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1705 | Param=read_GUI(hseries); |
---|
1706 | Param.Action.RUN=1; |
---|
1707 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1708 | if isfield(Param.ActionInput,'Fix1') |
---|
1709 | Param.ActionInput=rmfield(Param.ActionInput,'Fix1'); |
---|
1710 | end |
---|
1711 | if isfield(Param.ActionInput,'Patch1') |
---|
1712 | Param.ActionInput=rmfield(Param.ActionInput,'Patch1'); |
---|
1713 | end |
---|
1714 | if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 |
---|
1715 | Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); |
---|
1716 | end |
---|
1717 | if isfield(Param.ActionInput,'Fix2') |
---|
1718 | Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); |
---|
1719 | end |
---|
1720 | if isfield(Param.ActionInput,'Patch2') |
---|
1721 | Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); |
---|
1722 | end |
---|
1723 | if isfield(Param,'OutputSubDir') |
---|
1724 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1725 | end |
---|
1726 | Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B) |
---|
1727 | Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); |
---|
1728 | Param.IndexRange.last_i=str2num(get(handles.ref_i,'String')); |
---|
1729 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
1730 | Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); |
---|
1731 | Param.IndexRange.last_j=Param.IndexRange.first_j; |
---|
1732 | else |
---|
1733 | Param.IndexRange.first_j=1; |
---|
1734 | Param.IndexRange.last_j=1; |
---|
1735 | end |
---|
1736 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1737 | if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series |
---|
1738 | |
---|
1739 | %% create image data ImageData for display |
---|
1740 | ImageData.ListVarName={'ny','nx','A'}; |
---|
1741 | ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
1742 | ImageData.VarAttribute{1}.Role='coord_y'; |
---|
1743 | ImageData.VarAttribute{2}.Role='coord_x'; |
---|
1744 | ImageData.VarAttribute{3}.Role='scalar'; |
---|
1745 | ImageData.A=imread(Data.Civ1_ImageA); % read the first image |
---|
1746 | if ndims(ImageData.A)==3 %case of color image |
---|
1747 | ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
1748 | end |
---|
1749 | ImageData.ny=[size(ImageData.A,1) 1]; |
---|
1750 | ImageData.nx=[1 size(ImageData.A,2)]; |
---|
1751 | ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly |
---|
1752 | |
---|
1753 | %% create the figure view_field for image visualization |
---|
1754 | hview_field=view_field(ImageData); %view the image in the GUI view_field |
---|
1755 | set(0,'CurrentFigure',hview_field) |
---|
1756 | hhview_field=guihandles(hview_field); |
---|
1757 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
1758 | ViewData=get(hview_field,'UserData'); |
---|
1759 | ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field |
---|
1760 | ViewData.PlotAxes.X=Data.Civ1_X'; |
---|
1761 | ViewData.PlotAxes.Y=Data.Civ1_Y'; |
---|
1762 | ViewData.PlotAxes.B=imread(Data.Civ1_ImageB);%store the second image in the UserData of the GUI view_field |
---|
1763 | set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field |
---|
1764 | |
---|
1765 | %% look for a current figure for image correlation display |
---|
1766 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
1767 | if isempty(corrfig) |
---|
1768 | corrfig=figure; |
---|
1769 | set(corrfig,'tag','corrfig') |
---|
1770 | set(corrfig,'name','image correlation') |
---|
1771 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
1772 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
1773 | else |
---|
1774 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
1775 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1776 | if ~isempty(corrfig) |
---|
1777 | delete(corrfig) |
---|
1778 | end |
---|
1779 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1780 | if ~isempty(hview_field) |
---|
1781 | delete(hview_field) |
---|
1782 | end |
---|
1783 | end |
---|
1784 | else |
---|
1785 | hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field |
---|
1786 | if ~isempty(hview_field) |
---|
1787 | delete(hview_field) |
---|
1788 | end |
---|
1789 | end |
---|
1790 | |
---|
1791 | % -------------------------------------------------------------------- |
---|
1792 | % --- Executes on button press in TestPatch1. |
---|
1793 | % -------------------------------------------------------------------- |
---|
1794 | function TestPatch1_Callback(hObject, eventdata, handles) |
---|
1795 | |
---|
1796 | if get(handles.TestPatch1,'Value')% if TestPatch1 is activated |
---|
1797 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1798 | Param=read_GUI(hseries); |
---|
1799 | CivDir=fullfile(Param.OutputPath,Param.Experiment,Param.Device,[Param.OutputSubDir Param.OutputDirExt]); |
---|
1800 | % ListXml=dir(CivXmlDir); |
---|
1801 | if exist(CivDir,'dir') |
---|
1802 | CivFile=uigetfile_uvmat('pick .nc file with civ1-fix1 data',CivDir,'.nc'); |
---|
1803 | [Field,VelTypeOut,errormsg]=read_civdata(CivFile) |
---|
1804 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
1805 | r=regexp(Field.ListGlobalAttribute{ilist},'Civ1_(?<field>.+)','names');% \D = not a digit, \d =digi |
---|
1806 | if ~isempty(r) |
---|
1807 | ParamTest.Civ1.(r.field)=(Field.(['Civ1_' r.field])); |
---|
1808 | end |
---|
1809 | r=regexp(Field.ListGlobalAttribute{ilist},'Fix1_(?<field>.+)','names');% \D = not a digit, \d =digi |
---|
1810 | if ~isempty(r) |
---|
1811 | ParamTest.Fix1.(r.field)=(Field.(['Fix1_' r.field])); |
---|
1812 | end |
---|
1813 | end |
---|
1814 | fill_GUI(ParamTest,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
1815 | drawnow |
---|
1816 | update_CivOptions(handles,0) |
---|
1817 | |
---|
1818 | set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation |
---|
1819 | % set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed |
---|
1820 | Param.Action.RUN=1; |
---|
1821 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1822 | Param.ActionInput.CheckCiv1=0;% do not repeat Civ1 computation |
---|
1823 | if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 |
---|
1824 | Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); |
---|
1825 | end |
---|
1826 | if isfield(Param.ActionInput,'Fix2') |
---|
1827 | Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); |
---|
1828 | end |
---|
1829 | if isfield(Param.ActionInput,'Patch2') |
---|
1830 | Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); |
---|
1831 | end |
---|
1832 | if isfield(Param,'OutputSubDir') |
---|
1833 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1834 | end |
---|
1835 | ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters |
---|
1836 | Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch |
---|
1837 | Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); |
---|
1838 | Param.IndexRange.last_i=Param.IndexRange.first_i; |
---|
1839 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
1840 | Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); |
---|
1841 | Param.IndexRange.last_j=Param.IndexRange.first_j; |
---|
1842 | else |
---|
1843 | Param.IndexRange.first_j=1; |
---|
1844 | Param.IndexRange.last_j=1; |
---|
1845 | end |
---|
1846 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1847 | bckcolor=get(handles.civ_input,'Color'); |
---|
1848 | set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished |
---|
1849 | |
---|
1850 | %% prepare Param for iterative Patch processing without input file reading |
---|
1851 | Param.Civ1_X=Data.Civ1_X; |
---|
1852 | Param.Civ1_Y=Data.Civ1_Y; |
---|
1853 | Param.Civ1_U=Data.Civ1_U; |
---|
1854 | Param.Civ1_V=Data.Civ1_V; |
---|
1855 | Param.Civ1_FF=Data.Civ1_FF; |
---|
1856 | Param=rmfield(Param,'InputTable');%desactivate input file reading |
---|
1857 | if isfield(Param.ActionInput,'Civ1') |
---|
1858 | Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant |
---|
1859 | end |
---|
1860 | if isfield(Param.ActionInput,'Fix1') |
---|
1861 | Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant |
---|
1862 | end |
---|
1863 | SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value |
---|
1864 | NbGood=numel(find(Data.Civ1_FF==0)); |
---|
1865 | NbExclude=zeros(1,7);% initialize the set of smoothing parameters |
---|
1866 | DiffVel=zeros(1,7);% initialize the rms difference between patch and civ |
---|
1867 | Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters |
---|
1868 | for irho=1:7 |
---|
1869 | Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho); |
---|
1870 | [Data,errormsg]= civ_series(Param);%apply the processing fct |
---|
1871 | if ~isempty(errormsg) |
---|
1872 | msgbox_uvmat('ERROR',errormsg) |
---|
1873 | return |
---|
1874 | end |
---|
1875 | ind_good=find(Data.Civ1_FF==0); |
---|
1876 | Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good); |
---|
1877 | Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good); |
---|
1878 | DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff)); |
---|
1879 | NbExclude(irho)=(NbGood-numel(ind_good))/NbGood; |
---|
1880 | end |
---|
1881 | figure(1) |
---|
1882 | semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m') |
---|
1883 | grid on |
---|
1884 | legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1') |
---|
1885 | xlabel('smoothing parameter') |
---|
1886 | ylabel('smoothing effect') |
---|
1887 | set(handles.TestPatch1,'BackgroundColor',[0 1 0]) |
---|
1888 | else |
---|
1889 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1890 | if ~isempty(corrfig) |
---|
1891 | delete(corrfig) |
---|
1892 | end |
---|
1893 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1894 | if ~isempty(hview_field) |
---|
1895 | delete(hview_field) |
---|
1896 | end |
---|
1897 | end |
---|
1898 | else |
---|
1899 | msgbox_uvmat('ERROR','no output file: first perform a civ1-fix1 computation') |
---|
1900 | return |
---|
1901 | end |
---|
1902 | |
---|
1903 | %------------------------------------------------------------------------ |
---|
1904 | % --- Executes on button press in TestCiv2. |
---|
1905 | %------------------------------------------------------------------------ |
---|
1906 | function TestCiv2_Callback(hObject, eventdata, handles) |
---|
1907 | drawnow |
---|
1908 | if get(handles.TestCiv2,'Value') |
---|
1909 | set(handles.TestCiv2,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch |
---|
1910 | set(handles.CheckFix2,'value',0)% desactivate next step |
---|
1911 | set(handles.CheckPatch2,'value',0)% desactivate next step |
---|
1912 | update_CivOptions(handles,0) |
---|
1913 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1914 | Param=read_GUI(hseries); |
---|
1915 | Param.Action.RUN=1; |
---|
1916 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1917 | if isfield(Param,'OutputSubDir') |
---|
1918 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1919 | end |
---|
1920 | Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B) |
---|
1921 | set(handles.Civ1,'BackgroundColor',[1 1 0]) |
---|
1922 | set(handles.Fix1,'BackgroundColor',[1 1 0]) |
---|
1923 | set(handles.Patch1,'BackgroundColor',[1 1 0]) |
---|
1924 | Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); |
---|
1925 | Param.IndexRange.last_i=Param.IndexRange.first_i; |
---|
1926 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
1927 | Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); |
---|
1928 | Param.IndexRange.last_j=Param.IndexRange.first_j; |
---|
1929 | else |
---|
1930 | Param.IndexRange.first_j=1; |
---|
1931 | Param.IndexRange.last_j=1; |
---|
1932 | end |
---|
1933 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1934 | |
---|
1935 | %% create image data ImageData for display |
---|
1936 | ImageData.ListVarName={'ny','nx','A'}; |
---|
1937 | ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
1938 | ImageData.A=imread(Data.Civ2_ImageA); % read the first image |
---|
1939 | if ndims(ImageData.A)==3 %case of color image |
---|
1940 | ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
1941 | end |
---|
1942 | ImageData.ny=[size(ImageData.A,1) 1]; |
---|
1943 | ImageData.nx=[1 size(ImageData.A,2)]; |
---|
1944 | ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly |
---|
1945 | |
---|
1946 | %% create the figure view_field for image visualization |
---|
1947 | hview_field=view_field(ImageData); %view the image in the GUI view_field |
---|
1948 | set(0,'CurrentFigure',hview_field) |
---|
1949 | % plot the boundaries of the subdomains used for patch |
---|
1950 | for isub=1:size(Data.Civ1_SubRange,3); |
---|
1951 | pos_x=Data.Civ1_SubRange(1,1,isub); |
---|
1952 | pos_y=Data.Civ1_SubRange(2,1,isub); |
---|
1953 | width=Data.Civ1_SubRange(1,2,isub)-Data.Civ1_SubRange(1,1,isub); |
---|
1954 | height=Data.Civ1_SubRange(2,2,isub)-Data.Civ1_SubRange(2,1,isub); |
---|
1955 | rectangle('Position',[pos_x pos_y width height],'EdgeColor',[0 0 1]) |
---|
1956 | end |
---|
1957 | hhview_field=guihandles(hview_field);% |
---|
1958 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
1959 | ViewData=get(hview_field,'UserData'); % get the currently plotted field (the image A) |
---|
1960 | % store info in the UserData of view-field |
---|
1961 | ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field |
---|
1962 | ViewData.PlotAxes.B=imread(Data.Civ2_ImageB);%store the second image in the UserData of the GUI view_field |
---|
1963 | ViewData.PlotAxes.X=Data.Civ2_X'; |
---|
1964 | ViewData.PlotAxes.Y=Data.Civ2_Y'; |
---|
1965 | ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by the preliminary run of civ2 |
---|
1966 | ViewData.PlotAxes.ShiftY=Data.Civ2_V'; |
---|
1967 | ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange; |
---|
1968 | ViewData.PlotAxes.Civ1_NbCentres=Data.Civ1_NbCentres; |
---|
1969 | ViewData.PlotAxes.Civ1_Coord_tps=Data.Civ1_Coord_tps; |
---|
1970 | ViewData.PlotAxes.Civ1_U_tps=Data.Civ1_U_tps; |
---|
1971 | ViewData.PlotAxes.Civ1_V_tps=Data.Civ1_V_tps; |
---|
1972 | ViewData.PlotAxes.Civ1_Dt=Data.Civ1_Dt; |
---|
1973 | ViewData.PlotAxes.Civ2_Dt=Data.Civ2_Dt; |
---|
1974 | set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field |
---|
1975 | bckcolor=get(handles.civ_input,'Color'); |
---|
1976 | set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calmculation is finished |
---|
1977 | set(handles.Fix1,'BackgroundColor',bckcolor) |
---|
1978 | set(handles.Patch1,'BackgroundColor',bckcolor) |
---|
1979 | drawnow |
---|
1980 | |
---|
1981 | %% look for a current figure for image correlation display |
---|
1982 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
1983 | if isempty(corrfig) |
---|
1984 | corrfig=figure; |
---|
1985 | set(corrfig,'tag','corrfig') |
---|
1986 | set(corrfig,'name','image correlation') |
---|
1987 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
1988 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
1989 | else |
---|
1990 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
1991 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1992 | if ~isempty(corrfig) |
---|
1993 | delete(corrfig) |
---|
1994 | end |
---|
1995 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1996 | if ~isempty(hview_field) |
---|
1997 | delete(hview_field) |
---|
1998 | end |
---|
1999 | end |
---|
2000 | else |
---|
2001 | hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field |
---|
2002 | if ~isempty(hview_field) |
---|
2003 | delete(hview_field) |
---|
2004 | end |
---|
2005 | end |
---|
2006 | |
---|
2007 | |
---|
2008 | % --- Executes on button press in TestPatch2. |
---|
2009 | function TestPatch2_Callback(hObject, eventdata, handles) |
---|
2010 | if get(handles.TestPatch2,'Value')% if TestPatch2 is activated |
---|
2011 | set(handles.TestPatch2,'BackgroundColor',[1 1 0])%paint TestPatch2 button in yellow to indicate activation |
---|
2012 | set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is activated |
---|
2013 | set(handles.Fix1,'BackgroundColor',[1 1 0])% indicate fix1 calculation is activated |
---|
2014 | set(handles.Patch1,'BackgroundColor',[1 1 0])% indicate Patch1 calculation is activated |
---|
2015 | set(handles.Civ2,'BackgroundColor',[1 1 0])% indicate civ2 calculation is activated |
---|
2016 | set(handles.Fix2,'BackgroundColor',[1 1 0])% indicate fix2 calculation is activated |
---|
2017 | hseries=findobj(allchild(0),'Tag','series'); |
---|
2018 | Param=read_GUI(hseries); |
---|
2019 | Param.Action.RUN=1; |
---|
2020 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
2021 | if isfield(Param,'OutputSubDir') |
---|
2022 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
2023 | end |
---|
2024 | ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters |
---|
2025 | Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch |
---|
2026 | Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); |
---|
2027 | Param.IndexRange.last_i=Param.IndexRange.first_i; |
---|
2028 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
2029 | Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); |
---|
2030 | Param.IndexRange.last_j=Param.IndexRange.first_j; |
---|
2031 | else |
---|
2032 | Param.IndexRange.first_j=1; |
---|
2033 | Param.IndexRange.last_j=1; |
---|
2034 | end |
---|
2035 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
2036 | bckcolor=get(handles.civ_input,'Color'); |
---|
2037 | set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished |
---|
2038 | set(handles.Fix1,'BackgroundColor',bckcolor)% indicate fix1 calculation is finished |
---|
2039 | set(handles.Patch1,'BackgroundColor',bckcolor)% indicate Patch1 calculation is finished |
---|
2040 | set(handles.Civ2,'BackgroundColor',bckcolor)% indicate civ2 calculation is finished |
---|
2041 | set(handles.Fix2,'BackgroundColor',bckcolor)% indicate fix2 calculation is finished |
---|
2042 | |
---|
2043 | %% prepare Param for iterative Patch processing without input file reading |
---|
2044 | Param.Civ2_X=Data.Civ2_X; |
---|
2045 | Param.Civ2_Y=Data.Civ2_Y; |
---|
2046 | Param.Civ2_U=Data.Civ2_U; |
---|
2047 | Param.Civ2_V=Data.Civ2_V; |
---|
2048 | Param.Civ2_FF=Data.Civ2_FF; |
---|
2049 | Param=rmfield(Param,'InputTable');%desactivate input file reading |
---|
2050 | if isfield(Param.ActionInput,'Civ1') |
---|
2051 | Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant |
---|
2052 | end |
---|
2053 | if isfield(Param.ActionInput,'Fix1') |
---|
2054 | Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant |
---|
2055 | end |
---|
2056 | if isfield(Param.ActionInput,'Patch1') |
---|
2057 | Param.ActionInput=rmfield(Param.ActionInput,'Patch1');%desactivate fix1:remove fix1 input param if relevant |
---|
2058 | end |
---|
2059 | if isfield(Param.ActionInput,'Civ2') |
---|
2060 | Param.ActionInput=rmfield(Param.ActionInput,'Civ2');%desactivate civ2: remove civ2 input param if relevant |
---|
2061 | end |
---|
2062 | if isfield(Param.ActionInput,'Fix2') |
---|
2063 | Param.ActionInput=rmfield(Param.ActionInput,'Fix2');%desactivate fix1:remove fix1 input param if relevant |
---|
2064 | end |
---|
2065 | SmoothingParam=(ParamPatch2.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value |
---|
2066 | NbGood=numel(find(Data.Civ2_FF==0)); |
---|
2067 | NbExclude=zeros(1,7);% initialize the set of smoothing parameters |
---|
2068 | DiffVel=zeros(1,7);% initialize the rms difference between patch and civ |
---|
2069 | Param.ActionInput.Patch2=ParamPatch2;% retrieve Patch2 parameters |
---|
2070 | for irho=1:7 |
---|
2071 | Param.ActionInput.Patch2.FieldSmooth=SmoothingParam(irho); |
---|
2072 | [Data,errormsg]= civ_series(Param);%apply the processing fct |
---|
2073 | if ~isempty(errormsg) |
---|
2074 | msgbox_uvmat('ERROR',errormsg) |
---|
2075 | return |
---|
2076 | end |
---|
2077 | ind_good=find(Data.Civ2_FF==0); |
---|
2078 | Civ2_U_Diff=Data.Civ2_U(ind_good)-Data.Civ2_U_smooth(ind_good); |
---|
2079 | Civ2_V_Diff=Data.Civ2_V(ind_good)-Data.Civ2_V_smooth(ind_good); |
---|
2080 | DiffVel(irho)=sqrt(mean(Civ2_U_Diff.*Civ2_U_Diff+Civ2_V_Diff.*Civ2_V_Diff)); |
---|
2081 | NbExclude(irho)=(NbGood-numel(ind_good))/NbGood; |
---|
2082 | end |
---|
2083 | figure(1) |
---|
2084 | semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.1*ones(size(SmoothingParam)),'m') |
---|
2085 | grid on |
---|
2086 | legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended value diff. Patch2-Civ2') |
---|
2087 | xlabel('smoothing parameter') |
---|
2088 | ylabel('smoothing effect') |
---|
2089 | set(handles.TestPatch2,'BackgroundColor',[0 1 0]) |
---|
2090 | else |
---|
2091 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
2092 | if ~isempty(corrfig) |
---|
2093 | delete(corrfig) |
---|
2094 | end |
---|
2095 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
2096 | if ~isempty(hview_field) |
---|
2097 | delete(hview_field) |
---|
2098 | end |
---|
2099 | end |
---|
2100 | |
---|
2101 | |
---|
2102 | %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature |
---|
2103 | %--------------------------------------------------------------------- |
---|
2104 | function NomTypeNc=nomtype2pair(NomTypeIma,mode_selected) |
---|
2105 | %--------------------------------------------------------------------- |
---|
2106 | % OUTPUT: |
---|
2107 | % NomTypeNc |
---|
2108 | %--------------------------------------------------------------------- |
---|
2109 | % INPUT: |
---|
2110 | % 'NomTypeIma': string defining the kind of nomenclature used for images |
---|
2111 | |
---|
2112 | NomTypeNc=NomTypeIma;%default |
---|
2113 | switch mode_selected |
---|
2114 | case 'pair j1-j2' |
---|
2115 | if ~isempty(regexp(NomTypeIma,'a$')) |
---|
2116 | NomTypeNc=[NomTypeIma 'b']; |
---|
2117 | elseif ~isempty(regexp(NomTypeIma,'A$')) |
---|
2118 | NomTypeNc=[NomTypeIma 'B']; |
---|
2119 | else |
---|
2120 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
2121 | if ~isempty(r) |
---|
2122 | NomTypeNc='_1_1-2'; |
---|
2123 | end |
---|
2124 | end |
---|
2125 | case 'series(Dj)' |
---|
2126 | % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
2127 | % if ~isempty(r) |
---|
2128 | NomTypeNc='_1_1-2'; |
---|
2129 | % end |
---|
2130 | case 'series(Di)' |
---|
2131 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
2132 | if ~isempty(r) |
---|
2133 | NomTypeNc='_1-2_1'; |
---|
2134 | else |
---|
2135 | NomTypeNc='_1-2'; |
---|
2136 | end |
---|
2137 | end |
---|
2138 | |
---|
2139 | |
---|
2140 | %------------------------------------------------------------------------ |
---|
2141 | % --- determine the list of index pairs of processing file |
---|
2142 | function [ind1,ind2,mode_selected]=... |
---|
2143 | find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j) |
---|
2144 | %------------------------------------------------------------------------ |
---|
2145 | ind1=''; |
---|
2146 | ind2=''; |
---|
2147 | r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
2148 | if ~isempty(r) |
---|
2149 | mode_selected=['D' r.ind]; |
---|
2150 | ind1=stra2num(r.num1); |
---|
2151 | ind2=stra2num(r.num2); |
---|
2152 | else |
---|
2153 | mode_selected='burst'; |
---|
2154 | r=regexp(str_civ,'^j= (?<num1>[a-z])-(?<num2>[a-z])','names'); |
---|
2155 | if ~isempty(r) |
---|
2156 | NomTypeNc='_1ab'; |
---|
2157 | else |
---|
2158 | r=regexp(str_civ,'^j= (?<num1>[A-Z])-(?<num2>[A-Z])','names'); |
---|
2159 | if ~isempty(r) |
---|
2160 | NomTypeNc='_1AB'; |
---|
2161 | else |
---|
2162 | r=regexp(str_civ,'^j= (?<num1>\d+)-(?<num2>\d+)','names'); |
---|
2163 | if ~isempty(r) |
---|
2164 | NomTypeNc='_1_1-2'; |
---|
2165 | end |
---|
2166 | end |
---|
2167 | end |
---|
2168 | if isempty(r) |
---|
2169 | display('wrong pair mode input option') |
---|
2170 | else |
---|
2171 | ind1=stra2num(r.num1); |
---|
2172 | ind2=stra2num(r.num2); |
---|
2173 | end |
---|
2174 | end |
---|
2175 | |
---|
2176 | %------------------------------------------------------------------------ |
---|
2177 | % --- fill civ_input with the parameters retrieved from an input Civ file |
---|
2178 | %------------------------------------------------------------------------ |
---|
2179 | function fill_civ_input(Data,handles) |
---|
2180 | |
---|
2181 | %% Civ param |
---|
2182 | % lists of parameters to enter |
---|
2183 | ListParamNum={'CorrBoxSize','SearchBoxSize','SearchBoxShift','Dx','Dy','Dz','MinIma','MaxIma'};% list of numerical values (to transform in strings) |
---|
2184 | ListParamValue={'CorrSmooth','CheckGrid','CheckMask','CheckThreshold'}; |
---|
2185 | ListParamString={'Grid','Mask'}; |
---|
2186 | % CorrSmooth ?? |
---|
2187 | option={'Civ1','Civ2'}; |
---|
2188 | for ichoice=1:2 |
---|
2189 | if isfield(Data,[option{ichoice} '_CorrBoxSize']) |
---|
2190 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2191 | end |
---|
2192 | end |
---|
2193 | |
---|
2194 | %% Fix param |
---|
2195 | option={'Fix1','Fix2'}; |
---|
2196 | for ichoice=1:2 |
---|
2197 | if isfield(Data,[option{ichoice} '_CheckFmin2']) |
---|
2198 | ListParamNum={'MinVel','MaxVel','MinCorr'};% list of numerical values (to transform in strings) |
---|
2199 | ListParamValue={'CheckFmin2','CheckF3','CheckF4'}; |
---|
2200 | ListParamString={'ref_fix_1'}; |
---|
2201 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2202 | end |
---|
2203 | end |
---|
2204 | |
---|
2205 | %% Patch param |
---|
2206 | option={'Patch1','Patch2'}; |
---|
2207 | for ichoice=1:2 |
---|
2208 | if isfield(Data,[option{ichoice} '_FieldSmooth']) |
---|
2209 | ListParamNum={'FieldSmooth','MaxDiff','SubDomainSize'};% list of numerical values (to transform in strings) |
---|
2210 | ListParamValue={}; |
---|
2211 | ListParamString={}; |
---|
2212 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2213 | end |
---|
2214 | end |
---|
2215 | %------------------------------------------------------------------------ |
---|
2216 | % --- fill a panel of civ_input with the parameters retrieved from an input Civ file |
---|
2217 | %------------------------------------------------------------------------ |
---|
2218 | function fill_panel(Data,handles,panel,ListParamNum,ListParamValue,ListParamString) |
---|
2219 | children=get(handles.(panel),'children');%handles of the children of the input GUI with handle 'GUI_handle' |
---|
2220 | handles_panel=[]; |
---|
2221 | for ichild=1:numel(children) |
---|
2222 | if ~isempty(get(children(ichild),'tag')) |
---|
2223 | handles_panel.(get(children(ichild),'tag'))=children(ichild); |
---|
2224 | end |
---|
2225 | end |
---|
2226 | for ilist=1:numel(ListParamNum) |
---|
2227 | ParamName=ListParamNum{ilist}; |
---|
2228 | CivParamName=[panel '_' ParamName]; |
---|
2229 | if isfield(Data,CivParamName) |
---|
2230 | for icoord=1:numel(Data.(CivParamName)) |
---|
2231 | if numel(Data.(CivParamName))>1 |
---|
2232 | Tag=['num_' ParamName '_' num2str(icoord)]; |
---|
2233 | else |
---|
2234 | Tag=['num_' ParamName]; |
---|
2235 | end |
---|
2236 | if isfield(handles_panel,Tag) |
---|
2237 | set(handles_panel.(Tag),'String',num2str(Data.(CivParamName)(icoord))) |
---|
2238 | set(handles_panel.(Tag),'Visible','on') |
---|
2239 | end |
---|
2240 | end |
---|
2241 | end |
---|
2242 | end |
---|
2243 | for ilist=1:numel(ListParamValue) |
---|
2244 | ParamName=ListParamValue{ilist}; |
---|
2245 | CivParamName=[panel '_' ParamName]; |
---|
2246 | if strcmp(ParamName,'CorrSmooth') |
---|
2247 | ParamName=['num_' ParamName]; |
---|
2248 | end |
---|
2249 | if isfield(Data,CivParamName) |
---|
2250 | if isfield(handles_panel,ParamName) |
---|
2251 | set(handles_panel.(ParamName),'Value',Data.(CivParamName)) |
---|
2252 | end |
---|
2253 | end |
---|
2254 | end |
---|
2255 | for ilist=1:numel(ListParamString) |
---|
2256 | ParamName=ListParamString{ilist}; |
---|
2257 | CivParamName=[panel '_' ParamName]; |
---|
2258 | if isfield(Data,CivParamName) |
---|
2259 | if isfield(handles_panel,ParamName) |
---|
2260 | set(handles_panel.(ParamName),'String',Data.(CivParamName)) |
---|
2261 | end |
---|
2262 | end |
---|
2263 | end |
---|
2264 | |
---|
2265 | %------------------------------------------------------------------------ |
---|
2266 | % --- Executes on button press in ImportParam. |
---|
2267 | %------------------------------------------------------------------------ |
---|
2268 | function ImportParam_Callback(hObject, eventdata, handles) |
---|
2269 | hseries=findobj(allchild(0),'Tag','series'); |
---|
2270 | hhseries=guidata(hseries); |
---|
2271 | InputTable=get(hhseries.InputTable,'Data');% read the input file(s) table in the GUI series |
---|
2272 | oldfile=InputTable{1,1}; |
---|
2273 | if isempty(oldfile) |
---|
2274 | % use a file name stored in prefdir |
---|
2275 | dir_perso=prefdir; |
---|
2276 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2277 | if exist(profil_perso,'file') |
---|
2278 | h=load (profil_perso); |
---|
2279 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
2280 | oldfile=h.RootPath; |
---|
2281 | end |
---|
2282 | end |
---|
2283 | end |
---|
2284 | filexml=uigetfile_uvmat('pick a xml parameter file for civ',oldfile,'.xml');% get the xml file containing processing parameters |
---|
2285 | %proceed only if a file has been introduced by the browser |
---|
2286 | if ~isempty(filexml) |
---|
2287 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure |
---|
2288 | if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange') |
---|
2289 | msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''') |
---|
2290 | return |
---|
2291 | end |
---|
2292 | check_input=0; |
---|
2293 | if isfield(Param,'ActionInput') |
---|
2294 | if isfield(Param.ActionInput,'Program')&& strcmp(Param.ActionInput.Program,'civ_series') |
---|
2295 | fill_GUI(Param.ActionInput,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
2296 | set(handles.ConfigSource,'String',filexml) |
---|
2297 | check_input=1; |
---|
2298 | update_CivOptions(handles,0) |
---|
2299 | end |
---|
2300 | end |
---|
2301 | if ~check_input |
---|
2302 | msgbox_uvmat('ERROR','invalid config file (not for civ_series') |
---|
2303 | return |
---|
2304 | end |
---|
2305 | end |
---|
2306 | |
---|
2307 | %------------------------------------------------------------------------ |
---|
2308 | % --- Executes on selection change in CheckCiv3. |
---|
2309 | %------------------------------------------------------------------------ |
---|
2310 | function CheckCiv3_Callback(hObject, eventdata, handles) |
---|
2311 | |
---|
2312 | %------------------------------------------------------------------------ |
---|
2313 | % --- Executes on button press in CheckRefFile. |
---|
2314 | %------------------------------------------------------------------------ |
---|
2315 | function CheckRefFile_Callback(hObject, eventdata, handles) |
---|
2316 | |
---|
2317 | hseries=findobj(allchild(0),'Tag','series'); |
---|
2318 | hhseries=guidata(hseries); |
---|
2319 | InputTable=get(hhseries.InputTable,'Data'); |
---|
2320 | i1=str2num(get(hhseries.num_first_i,'String')); |
---|
2321 | j1=str2num(get(hhseries.num_first_j,'String')); |
---|
2322 | InputFile=fullfile_uvmat(InputTable{1,1},InputTable{1,2},InputTable{1,3},InputTable{1,5},InputTable{1,4},i1,[],j1); |
---|
2323 | % browse for a reference file for displacement |
---|
2324 | fileref= uigetfile_uvmat('pick a reference image file:',InputFile); |
---|
2325 | if ~isempty(fileref) |
---|
2326 | FileInfo=get_file_info(fileref); |
---|
2327 | CheckImage=strcmp(FileInfo.FieldType,'image');% =1 for images |
---|
2328 | if ~CheckImage |
---|
2329 | msgbox_uvmat('ERROR',['invalid file type input for reference image: ' FileInfo.FileType ' not an image']) |
---|
2330 | else |
---|
2331 | if isfield (FileInfo,'NumberOfFrames')&& FileInfo.NumberOfFrames>1 |
---|
2332 | set(handles.num_OriginIndex,'Visible','on') |
---|
2333 | set(handles.OriginIndex_title,'Visible','on') |
---|
2334 | else |
---|
2335 | set(handles.num_OriginIndex,'Visible','off') |
---|
2336 | set(handles.OriginIndex_title,'Visible','off') |
---|
2337 | end |
---|
2338 | set(handles.RefFile,'String',fileref) |
---|
2339 | set(handles.ConfigSource,'String','NEW') |
---|
2340 | set(handles.ConfigSource,'BackgroundColor',[1 0 1]) |
---|
2341 | end |
---|
2342 | end |
---|
2343 | |
---|
2344 | %------------------------------------------------------------------------ |
---|
2345 | % --- Executes on key press with selection of a uicontrol |
---|
2346 | %------------------------------------------------------------------------ |
---|
2347 | function keyboard_callback(hObject,eventdata,handles) |
---|
2348 | |
---|
2349 | ListExclude={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2','ref_i'}; |
---|
2350 | if isempty(find(strcmp(get(gco,'Tag'),ListExclude),1))% if the selected uicontrol is not in the Exclude list |
---|
2351 | set(handles.ConfigSource,'String','NEW')% indicate that the configuration is new |
---|
2352 | set(handles.OK,'BackgroundColor',[1 0 1])% |
---|
2353 | drawnow |
---|
2354 | end |
---|