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