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