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