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