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