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