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