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