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