[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 |
---|
[810] | 10 | |
---|
| 11 | %======================================================================= |
---|
[1126] | 12 | % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[810] | 13 | % http://www.legi.grenoble-inp.fr |
---|
[1127] | 14 | % Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr |
---|
[647] | 15 | % |
---|
[597] | 16 | % This file is part of the toolbox UVMAT. |
---|
| 17 | % |
---|
| 18 | % UVMAT is free software; you can redistribute it and/or modify |
---|
[810] | 19 | % it under the terms of the GNU General Public License as published |
---|
| 20 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 21 | % or (at your option) any later version. |
---|
[597] | 22 | % |
---|
| 23 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[810] | 26 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 27 | %======================================================================= |
---|
| 28 | |
---|
[597] | 29 | function varargout = civ_input(varargin) |
---|
| 30 | |
---|
| 31 | gui_Singleton = 1; |
---|
| 32 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 33 | 'gui_Singleton', gui_Singleton, ... |
---|
| 34 | 'gui_OpeningFcn', @civ_input_OpeningFcn, ... |
---|
| 35 | 'gui_OutputFcn', @civ_input_OutputFcn, ... |
---|
| 36 | 'gui_LayoutFcn', [] , ... |
---|
| 37 | 'gui_Callback', []); |
---|
| 38 | |
---|
[598] | 39 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback$','once')) |
---|
[597] | 40 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 41 | end |
---|
| 42 | |
---|
| 43 | if nargout |
---|
| 44 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 45 | else |
---|
| 46 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 47 | end |
---|
| 48 | |
---|
| 49 | % End initialization code - DO NOT EDIT |
---|
| 50 | |
---|
| 51 | %------------------------------------------------------------------------ |
---|
| 52 | % --- Executes just before civ_input is made visible. |
---|
| 53 | function civ_input_OpeningFcn(hObject, eventdata, handles, Param) |
---|
| 54 | %------------------------------------------------------------------------ |
---|
| 55 | % This function has no output args, see OutputFcn. |
---|
| 56 | |
---|
| 57 | %% General settings |
---|
| 58 | handles.output = Param; |
---|
| 59 | guidata(hObject, handles); % Update handles structure |
---|
| 60 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[774] | 61 | set(hObject,'WindowKeyPressFcn',{@keyboard_callback,handles})%set keyboard action function |
---|
| 62 | set(handles.ref_i,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function |
---|
[851] | 63 | set(handles.ref_j,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function |
---|
[774] | 64 | hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' |
---|
| 65 | hhseries=guidata(hseries); %handles of the elements in 'series' |
---|
| 66 | SeriesData=get(hseries,'UserData');% info stored in the GUI series |
---|
[597] | 67 | |
---|
[833] | 68 | %% set visibility options depending on the calling function (Param.Action.ActionName): |
---|
| 69 | switch Param.Action.ActionName |
---|
| 70 | case 'stereo_civ' |
---|
| 71 | set(handles.ListCompareMode,'Visible','off') |
---|
| 72 | set(handles.PairIndices,'Visible','off') |
---|
| 73 | case 'civ_series' |
---|
| 74 | set(handles.ListCompareMode,'Visible','on') |
---|
| 75 | set(handles.PairIndices,'Visible','on') |
---|
[1148] | 76 | case 'civ_3D' |
---|
| 77 | set(handles.ListCompareMode,'Visible','on') |
---|
| 78 | set(handles.PairIndices,'Visible','on') |
---|
| 79 | set(handles.title_z,'Visible','on') |
---|
| 80 | set(handles.num_CorrBoxSize_3,'Visible','on') |
---|
| 81 | set(handles.num_SearchBoxSize_3,'Visible','on') |
---|
| 82 | set(handles.num_SearchBoxShift_3,'Visible','on') |
---|
| 83 | set(handles.num_Dz,'Visible','on') |
---|
| 84 | set(handles.title_Dz,'Visible','on') |
---|
[833] | 85 | end |
---|
[599] | 86 | |
---|
| 87 | %% input file info |
---|
| 88 | NomTypeInput=Param.InputTable{1,4}; |
---|
[716] | 89 | FileType='image';%fdefault |
---|
| 90 | FileInfo=[]; |
---|
[1143] | 91 | if isfield(SeriesData,'FileInfo') |
---|
[1033] | 92 | FileType=SeriesData.FileInfo{1}.FileType;% info on the first input file series |
---|
| 93 | FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series |
---|
[711] | 94 | else |
---|
[774] | 95 | set(hhseries.REFRESH,'BackgroundColor',[1 0 1])% indicate that the file input in series needs to be refreshed |
---|
[711] | 96 | end |
---|
[599] | 97 | |
---|
[774] | 98 | %% case of netcdf file as input, read the processing stage and look for corresponding images |
---|
[599] | 99 | ind_opening=0;%default |
---|
| 100 | NomTypeNc=''; |
---|
[851] | 101 | NomTypeImaA=NomTypeInput; |
---|
| 102 | iview_image=1;%line # for the input images |
---|
[599] | 103 | switch FileType |
---|
| 104 | case 'civdata' |
---|
[603] | 105 | if ~strcmp(Param.Action.ActionName,'civ_series') |
---|
| 106 | msgbox_uvmat('ERROR','bad input data file: open an image or a nc file from civ_series') |
---|
[851] | 107 | return |
---|
[603] | 108 | end |
---|
[599] | 109 | NomTypeNc=NomTypeInput; |
---|
[1122] | 110 | ind_opening=SeriesData.FileInfo{1}.CivStage; |
---|
[599] | 111 | if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) |
---|
[1155] | 112 | set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomenclature does not involve index pairs |
---|
[599] | 113 | else |
---|
| 114 | set(handles.ListCompareMode,'Value',1) |
---|
| 115 | end |
---|
[1155] | 116 | [Data,~,~,errormsg]=nc2struct(SeriesData.FileInfo{1}.FileName,[]); |
---|
[774] | 117 | if ~isempty(errormsg) |
---|
| 118 | msgbox_uvmat('ERROR',['error in netcdf input file: ' errormsg]) |
---|
| 119 | return |
---|
| 120 | end |
---|
[910] | 121 | if isfield(Data,'.Civ1_ImageA') |
---|
[1155] | 122 | %[PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);%look for the source image A |
---|
| 123 | %[PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);%look for the source image B |
---|
[910] | 124 | end |
---|
[774] | 125 | if isfield(Data,'Civ2_ImageA') |
---|
[1155] | 126 | %[PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA); |
---|
| 127 | %[PathCiv2_ImageB,Civ2_ImageB,FileExtA]=fileparts(Data.Civ2_ImageB); |
---|
[637] | 128 | end |
---|
| 129 | if size(Param.InputTable,1)==1 |
---|
[910] | 130 | if isfield(Data,'.Civ1_ImageA') |
---|
[661] | 131 | series('display_file_name',hhseries,Data.Civ1_ImageA,'append');%append the image series to the input list |
---|
[1155] | 132 | [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA); |
---|
| 133 | % [~,~,~,~,~,~,~,~,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB); |
---|
[910] | 134 | else |
---|
| 135 | series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list |
---|
[1155] | 136 | [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA); |
---|
| 137 | %[RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ2_ImageB); |
---|
[910] | 138 | end |
---|
[637] | 139 | end |
---|
[910] | 140 | |
---|
[642] | 141 | iview_image=2;%line # for the input images |
---|
[761] | 142 | otherwise |
---|
[1154] | 143 | % if ~strcmp(FileType,'image') |
---|
| 144 | % msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input') |
---|
| 145 | % return |
---|
| 146 | % end |
---|
[599] | 147 | end |
---|
[598] | 148 | |
---|
| 149 | %% prepare the GUI with input parameters |
---|
[833] | 150 | % |
---|
[599] | 151 | set(handles.ref_i,'String',num2str(Param.IndexRange.first_i)) |
---|
| 152 | if isfield(Param.IndexRange,'first_j') |
---|
[603] | 153 | set(handles.ref_j,'String',num2str(Param.IndexRange.first_j)) |
---|
[597] | 154 | end |
---|
[856] | 155 | set(handles.ConfigSource,'String','\default') |
---|
[599] | 156 | |
---|
[774] | 157 | %% set the menus of image pairs and default selection for civ_input %%%%%%%%%%%%%%%%%%% |
---|
| 158 | |
---|
| 159 | %% display the min and max indices for the whole file series |
---|
[855] | 160 | if isempty(Param.IndexRange.MaxIndex_i)|| isempty(Param.IndexRange.MinIndex_i) |
---|
| 161 | msgbox_uvmat('ERROR','REFRESH the input files in the GUI series') |
---|
| 162 | return |
---|
| 163 | end |
---|
[776] | 164 | MaxIndex_i=Param.IndexRange.MaxIndex_i(iview_image); |
---|
| 165 | MinIndex_i=Param.IndexRange.MinIndex_i(iview_image); |
---|
| 166 | MaxIndex_j=1;%default |
---|
| 167 | MinIndex_j=1; |
---|
| 168 | if isfield(Param.IndexRange,'MaxIndex_j')&&isfield(Param.IndexRange,'MinIndex_j')... |
---|
| 169 | && numel(Param.IndexRange.MaxIndex_j')>=iview_image &&numel(Param.IndexRange.MinIndex_j')>=iview_image |
---|
| 170 | MaxIndex_j=Param.IndexRange.MaxIndex_j(iview_image); |
---|
| 171 | MinIndex_j=Param.IndexRange.MinIndex_j(iview_image); |
---|
[597] | 172 | end |
---|
[776] | 173 | %update the bounds if possible |
---|
| 174 | if isfield(SeriesData,'i1_series')&&numel(SeriesData.i1_series)>=iview_image |
---|
| 175 | if size(SeriesData.i1_series{iview_image},2)==2 && min(min(SeriesData.i1_series{iview_image}(:,1,:)))==0 |
---|
| 176 | MinIndex_j=1;% index j set to 1 by default |
---|
| 177 | MaxIndex_j=1; |
---|
| 178 | MinIndex_i=find(SeriesData.i1_series{iview_image}(1,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) |
---|
| 179 | MaxIndex_i=find(SeriesData.i1_series{iview_image}(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series) |
---|
| 180 | else |
---|
| 181 | ref_i=squeeze(max(SeriesData.i1_series{iview_image}(1,:,:),[],2));% select ref_j index for each ref_i |
---|
| 182 | ref_j=squeeze(max(SeriesData.j1_series{iview_image}(1,:,:),[],3));% select ref_i index for each ref_j |
---|
| 183 | MinIndex_i=min(find(ref_i))-1; |
---|
| 184 | MaxIndex_i=max(find(ref_i))-1; |
---|
| 185 | MaxIndex_j=max(find(ref_j))-1; |
---|
| 186 | MinIndex_j=min(find(ref_j))-1; |
---|
| 187 | end |
---|
| 188 | end |
---|
[599] | 189 | |
---|
[918] | 190 | |
---|
[599] | 191 | %% transfer the time from the GUI series, or use file index by default |
---|
| 192 | time=[]; |
---|
| 193 | TimeUnit='frame'; %default |
---|
| 194 | CoordUnit='';%default |
---|
| 195 | pxcm_search=1; |
---|
[951] | 196 | if isfield(SeriesData,'Time') &&numel(SeriesData.Time')>=1 && ~isempty(SeriesData.Time{1}) |
---|
[599] | 197 | time=SeriesData.Time{1}; |
---|
| 198 | end |
---|
[609] | 199 | if isfield(Param.IndexRange,'TimeUnit')&&~isempty(Param.IndexRange.TimeUnit) |
---|
| 200 | TimeUnit=Param.IndexRange.TimeUnit; |
---|
[1020] | 201 | end |
---|
[599] | 202 | if isfield(SeriesData,'GeometryCalib') |
---|
| 203 | tsai=SeriesData.GeometryCalib; |
---|
| 204 | if isfield(tsai,'fx_fy') |
---|
| 205 | pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range |
---|
| 206 | end |
---|
| 207 | if isfield(tsai,'CoordUnit') |
---|
| 208 | CoordUnit=tsai.CoordUnit; |
---|
| 209 | end |
---|
| 210 | end |
---|
| 211 | |
---|
| 212 | %% timing display |
---|
| 213 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
| 214 | if numel(time)>=2 % if there are at least two time values to define dt |
---|
[1153] | 215 | if size(time,1)<MaxIndex_i |
---|
[599] | 216 | msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file'); |
---|
| 217 | elseif size(time,2)<MaxIndex_j |
---|
| 218 | msgbox_uvmat('WARNING','maximum j index restricted by the timing of the xml file'); |
---|
| 219 | end |
---|
| 220 | MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data |
---|
| 221 | MaxIndex_j=min(size(time,2),MaxIndex_j); |
---|
[851] | 222 | set(handles.TimeSource,'String',Param.IndexRange.TimeSource); |
---|
[599] | 223 | else |
---|
[851] | 224 | set(handles.TimeSource,'String',''); %xml file not used for timing |
---|
[599] | 225 | TimeUnit='frame'; |
---|
| 226 | time=ones(MaxIndex_j-MinIndex_j+1,1)*(MinIndex_i:MaxIndex_i); |
---|
| 227 | time=time+0.001*(MinIndex_j:MaxIndex_j)'*ones(1,MaxIndex_i-MinIndex_i+1); |
---|
| 228 | end |
---|
| 229 | CivInputData.Time=time; |
---|
[637] | 230 | CivInputData.NomTypeIma=NomTypeImaA; |
---|
[599] | 231 | set(handles.civ_input,'UserData',CivInputData) |
---|
| 232 | set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) |
---|
| 233 | set(handles.TimeUnit,'String',TimeUnit); |
---|
| 234 | set(handles.SearchRange,'UserData', pxcm_search); |
---|
| 235 | |
---|
[668] | 236 | |
---|
[774] | 237 | %% set the civ_input options, depending on the input file content if a nc file has been opened |
---|
| 238 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
| 239 | checkbox=zeros(size(ListOptions));%default |
---|
[851] | 240 | checkrefresh=0; |
---|
[774] | 241 | if ind_opening==0 %case of image opening, start with Civ1 |
---|
| 242 | for index=1:numel(ListOptions) |
---|
| 243 | checkbox(index)=get(handles.(ListOptions{index}),'Value'); |
---|
| 244 | end |
---|
| 245 | index_max=find(checkbox, 1, 'last' ); |
---|
| 246 | if isempty(index_max),index_max=1;end |
---|
| 247 | for index=1:index_max |
---|
| 248 | set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1 |
---|
| 249 | end |
---|
[851] | 250 | else %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed |
---|
[1153] | 251 | % if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&... |
---|
| 252 | % ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) |
---|
| 253 | for index = 1:min(ind_opening,5) |
---|
| 254 | set(handles.(ListOptions{index}),'value',0) |
---|
| 255 | fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file |
---|
| 256 | end |
---|
| 257 | if isempty(FileInfo) |
---|
| 258 | FileInfo.FileName=''; |
---|
| 259 | end |
---|
| 260 | set(handles.ConfigSource,'String',FileInfo.FileName); |
---|
| 261 | if ind_opening<6 |
---|
| 262 | for index = 1:ind_opening |
---|
| 263 | set(handles.(ListOptions{index}),'value',0) |
---|
| 264 | end |
---|
| 265 | for index = ind_opening+1:6 |
---|
| 266 | set(handles.(ListOptions{index}),'value',1) |
---|
| 267 | end |
---|
| 268 | set(handles.CheckCiv3,'Visible','off')% make visible the switch 'iterate/repet' for Civ2. |
---|
| 269 | set(handles.CheckCiv3,'Value',0)% select'iterate/repet' by default |
---|
| 270 | else |
---|
| 271 | for index = 1:3 |
---|
| 272 | set(handles.(ListOptions{index}),'value',0) |
---|
| 273 | end |
---|
| 274 | for index = 4:6 |
---|
| 275 | set(handles.(ListOptions{index}),'value',1) |
---|
| 276 | end |
---|
[855] | 277 | set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2. |
---|
[1153] | 278 | set(handles.CheckCiv3,'Value',1)% select'iterate/repet' by default |
---|
[774] | 279 | end |
---|
[1153] | 280 | checkrefresh=1; |
---|
| 281 | % end |
---|
| 282 | % if ind_opening==6 |
---|
| 283 | % set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2. |
---|
| 284 | % else |
---|
| 285 | % set(handles.CheckCiv3,'Visible','off') |
---|
| 286 | % end |
---|
[774] | 287 | end |
---|
| 288 | |
---|
[851] | 289 | %% introduce the stored Civ parameters if available (from previous input or ImportConfig in series) |
---|
| 290 | if ~checkrefresh && isfield(Param,'ActionInput')&& strcmp(Param.ActionInput.Program,Param.Action.ActionName)% the program fits with the stored data |
---|
| 291 | fill_GUI(Param.ActionInput,hObject);%fill the GUI with the parameters retrieved from the input Param |
---|
| 292 | hcheckgrid=findobj(handles.civ_input,'Tag','CheckGrid'); |
---|
| 293 | for ilist=1:numel(hcheckgrid) |
---|
| 294 | if get(hcheckgrid(ilist),'Value')% if a grid is used, do not show Dx and Dy for an automatic grid |
---|
| 295 | hparent=get(hcheckgrid(ilist),'parent');%handles of the parent panel |
---|
| 296 | hchildren=get(hparent,'children'); |
---|
| 297 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 298 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
| 299 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 300 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
| 301 | set(handle_dx,'Visible','off'); |
---|
| 302 | set(handle_dy,'Visible','off'); |
---|
| 303 | set(handle_title_dy,'Visible','off'); |
---|
| 304 | set(handle_title_dx,'Visible','off'); |
---|
| 305 | end |
---|
| 306 | end |
---|
[885] | 307 | if isfield(Param.ActionInput,'Civ2') |
---|
[1033] | 308 | CheckDeformation_Callback(hObject, eventdata, handles) |
---|
[885] | 309 | end |
---|
[851] | 310 | end |
---|
[1033] | 311 | if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ListCompareMode')&&... |
---|
| 312 | strcmp(Param.ActionInput.ListCompareMode,'displacement') |
---|
| 313 | set(handles.PairIndices,'Visible','off') |
---|
| 314 | set(handles.CheckRefFile,'Visible','on') |
---|
| 315 | else |
---|
| 316 | set(handles.CheckRefFile,'Visible','off') |
---|
| 317 | end |
---|
[1020] | 318 | |
---|
[1148] | 319 | %% reinitialise pair menus |
---|
| 320 | set(handles.ListPairMode,'Value',1) |
---|
| 321 | set(handles.ListPairMode,'String',{''}) |
---|
| 322 | set(handles.ListPairCiv1,'Value',1) |
---|
| 323 | set(handles.ListPairCiv1,'String',{''}) |
---|
| 324 | set(handles.ListPairCiv2,'Value',1) |
---|
| 325 | set(handles.ListPairCiv2,'String',{''}) |
---|
| 326 | |
---|
[918] | 327 | %% set the menu and default choice of civ pairs |
---|
[1148] | 328 | if isequal(MaxIndex_j,MinIndex_j)|| strcmp(Param.Action.ActionName,'civ_3D')% no possibility of j pairs |
---|
[1016] | 329 | PairMenu={'series(Di)'}; |
---|
[1141] | 330 | elseif MaxIndex_j-MinIndex_j==1 |
---|
| 331 | PairMenu={'pair j1-j2'}; |
---|
| 332 | elseif MaxIndex_i==MinIndex_i && MaxIndex_j-MinIndex_j>2% simple series in j |
---|
[1016] | 333 | PairMenu={'pair j1-j2';'series(Dj)'}; |
---|
[918] | 334 | else |
---|
[1016] | 335 | PairMenu={'pair j1-j2';'series(Dj)';'series(Di)'};%multiple choice |
---|
[918] | 336 | end |
---|
[1016] | 337 | set(handles.ListPairMode,'String',PairMenu) |
---|
[918] | 338 | |
---|
[1016] | 339 | %% set default choice of pair mode |
---|
[1097] | 340 | PairIndex=[]; |
---|
[1016] | 341 | if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'PairIndices') |
---|
[1097] | 342 | PairIndex=find(strcmp(Param.ActionInput.PairIndices.ListPairMode,PairMenu));%retrieve the previous option |
---|
[1016] | 343 | end |
---|
[1148] | 344 | if strcmp(Param.Action.ActionName,'civ_3D') |
---|
[1156] | 345 | PairIndex=1; |
---|
[1148] | 346 | else |
---|
| 347 | if isempty(PairIndex) |
---|
| 348 | if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs |
---|
| 349 | PairIndex=1; |
---|
| 350 | elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j |
---|
| 351 | if MaxIndex_j <= 10 |
---|
| 352 | PairIndex=1;% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
| 353 | end |
---|
[1097] | 354 | else |
---|
[1148] | 355 | if strcmp(NomTypeNc,'_1-2_1') |
---|
| 356 | PairIndex=3;% advise 'series(Di)' |
---|
| 357 | elseif MaxIndex_j <= 10 |
---|
| 358 | PairIndex=1;% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
| 359 | else |
---|
| 360 | PairIndex=2;% advice 'Dj' |
---|
| 361 | end |
---|
[1016] | 362 | end |
---|
| 363 | end |
---|
| 364 | end |
---|
[1148] | 365 | set(handles.ListPairMode,'Value',PairIndex); |
---|
[1016] | 366 | |
---|
[918] | 367 | %% indicate the min and max indices i and j on the GUI |
---|
| 368 | set(handles.MinIndex_i,'String',num2str(MinIndex_i)) |
---|
| 369 | set(handles.MaxIndex_i,'String',num2str(MaxIndex_i)) |
---|
| 370 | set(handles.MinIndex_j,'String',num2str(MinIndex_j)) |
---|
| 371 | set(handles.MaxIndex_j,'String',num2str(MaxIndex_j)) |
---|
| 372 | |
---|
[774] | 373 | %% set the reference indices from the input file indices |
---|
[852] | 374 | if ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) |
---|
[774] | 375 | update_CivOptions(handles,ind_opening)% fill the menu of possible pairs |
---|
[851] | 376 | end |
---|
[774] | 377 | |
---|
| 378 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
| 379 | ListPairMode_Callback([], [], handles) |
---|
| 380 | |
---|
[599] | 381 | %% set the GUI to modal: wait for OK to close |
---|
[598] | 382 | set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal |
---|
[597] | 383 | drawnow |
---|
[856] | 384 | uiwait(handles.civ_input);% wait for OK action to end the function |
---|
[597] | 385 | |
---|
[599] | 386 | |
---|
[597] | 387 | %------------------------------------------------------------------------ |
---|
| 388 | % --- Outputs from this function are returned to the command line. |
---|
| 389 | function varargout = civ_input_OutputFcn(hObject, eventdata, handles) |
---|
| 390 | %------------------------------------------------------------------------ |
---|
| 391 | % Get default command line output from handles structure |
---|
[668] | 392 | varargout{1}=[];% default output when civ_input is canceled (no 'OK') |
---|
| 393 | if ~isempty(handles) |
---|
| 394 | varargout{1} = handles.output; |
---|
| 395 | delete(handles.civ_input) |
---|
| 396 | end |
---|
[597] | 397 | |
---|
| 398 | % --- Executes when user attempts to close get_field. |
---|
[598] | 399 | function civ_input_CloseRequestFcn(hObject, eventdata, handles) |
---|
[597] | 400 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
| 401 | % The GUI is still in UIWAIT, us UIRESUME |
---|
[598] | 402 | uiresume(handles.civ_input); |
---|
[597] | 403 | else |
---|
| 404 | % The GUI is no longer waiting, just close it |
---|
[598] | 405 | delete(handles.civ_input); |
---|
[597] | 406 | end |
---|
| 407 | |
---|
[851] | 408 | %------------------------------------------------------------------------ |
---|
| 409 | % --- Executes on button press in SetDefaultParam. |
---|
| 410 | %------------------------------------------------------------------------ |
---|
| 411 | function SetDefaultParam_Callback(hObject, eventdata, handles) |
---|
| 412 | |
---|
[856] | 413 | Param.ConfigSource='\default'; |
---|
| 414 | |
---|
| 415 | %% Civ1 parameters |
---|
[874] | 416 | %Param.CheckCiv1=1; |
---|
[1148] | 417 | Param.Civ1.CorrBoxSize=[25 25 1]; |
---|
| 418 | Param.Civ1.SearchBoxSize=[55 55 5]; |
---|
[856] | 419 | Param.Civ1.SearchBoxShift=[0 0]; |
---|
| 420 | Param.Civ1.CorrSmooth=1; |
---|
| 421 | Param.Civ1.Dx=20; |
---|
| 422 | Param.Civ1.Dy=20; |
---|
| 423 | Param.Civ1.CheckGrid=0; |
---|
| 424 | Param.Civ1.CheckMask=0; |
---|
[873] | 425 | Param.Civ1.Mask=''; |
---|
[856] | 426 | Param.Civ1.CheckThreshold=0; |
---|
| 427 | Param.Civ1.TestCiv1=0; |
---|
| 428 | |
---|
| 429 | %% Fix1 parameters |
---|
| 430 | Param.Fix1.MinCorr=0.2000; |
---|
| 431 | |
---|
| 432 | %% Patch1 parameters |
---|
[874] | 433 | %Param.CheckPatch1=1; |
---|
[1148] | 434 | Param.Patch1.FieldSmooth=20; |
---|
| 435 | Param.Patch1.MaxDiff=2; |
---|
| 436 | Param.Patch1.SubDomainSize=125; |
---|
[856] | 437 | |
---|
| 438 | %% Civ2 parameters |
---|
[874] | 439 | %Param.CheckCiv2=1; |
---|
[856] | 440 | Param.Civ2.CorrBoxSize=[21 21]; |
---|
[862] | 441 | Param.Civ2.SearchBoxSize=[27 27]; |
---|
[856] | 442 | Param.Civ2.CorrSmooth=1; |
---|
| 443 | Param.Civ2.Dx=10; |
---|
| 444 | Param.Civ2.Dy=10; |
---|
| 445 | Param.Civ2.CheckGrid=0; |
---|
| 446 | Param.Civ2.CheckMask=0; |
---|
[873] | 447 | Param.Civ2.Mask=''; |
---|
[856] | 448 | Param.Civ2.CheckThreshold=0; |
---|
| 449 | |
---|
| 450 | %% Fix2 parameters |
---|
| 451 | Param.Fix2.MinCorr=0.2000; |
---|
| 452 | |
---|
| 453 | %% Patch2 parameters |
---|
[1148] | 454 | Param.Patch2.FieldSmooth=5; |
---|
[856] | 455 | Param.Patch2.MaxDiff=1.5000; |
---|
[1148] | 456 | Param.Patch2.SubDomainSize=250; |
---|
[856] | 457 | Param.Patch2.TestPatch2=0; |
---|
| 458 | |
---|
| 459 | fill_GUI(Param,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
[873] | 460 | update_CivOptions(handles,0) |
---|
[856] | 461 | |
---|
[597] | 462 | % ----------------------------------------------------------------------- |
---|
| 463 | % ----------------------------------------------------------------------- |
---|
| 464 | % --- Open the help html file |
---|
| 465 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 466 | % ----------------------------------------------------------------------- |
---|
[774] | 467 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#Civ') |
---|
[597] | 468 | |
---|
| 469 | %------------------------------------------------------------------------ |
---|
| 470 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
[604] | 471 | function Civ1_ImageB_Callback(hObject, eventdata, handles) |
---|
[597] | 472 | %------------------------------------------------------------------------ |
---|
[604] | 473 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
[597] | 474 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
| 475 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
| 476 | if isempty(ichoice) |
---|
| 477 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 478 | else |
---|
| 479 | ilist=ichoice; |
---|
| 480 | end |
---|
| 481 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
| 482 | if get(handles.CheckCiv1,'Value')% if Civ1 is performed |
---|
[604] | 483 | set(handles.Civ2_ImageA,'String',SubDir);% set by default civ2 directory the same as civ1 |
---|
[597] | 484 | % set(handles.ListSubdirCiv2,'Value',ilist) |
---|
| 485 | else % if Civ1 data already exist |
---|
[774] | 486 | errormsg=find_netcpair_civ(handles,1); %update the list of available index pairs in the new directory |
---|
[597] | 487 | if ~isempty(errormsg) |
---|
| 488 | msgbox_uvmat('ERROR',errormsg) |
---|
| 489 | end |
---|
| 490 | end |
---|
| 491 | |
---|
| 492 | %------------------------------------------------------------------------ |
---|
| 493 | % --- Executes on carriage return on the SubDir checkciv1 edit window |
---|
[604] | 494 | function Civ2_ImageA_Callback(hObject, eventdata, handles) |
---|
[597] | 495 | %------------------------------------------------------------------------ |
---|
[604] | 496 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
[597] | 497 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
| 498 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
| 499 | if isempty(ichoice) |
---|
| 500 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
| 501 | else |
---|
| 502 | ilist=ichoice; |
---|
| 503 | end |
---|
| 504 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
| 505 | %update the list of available pairs from netcdf files in the new directory |
---|
| 506 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
| 507 | errormsg=find_netcpair_civ(handles,2); |
---|
| 508 | if ~isempty(errormsg) |
---|
| 509 | msgbox_uvmat('ERROR',errormsg) |
---|
| 510 | end |
---|
| 511 | end |
---|
| 512 | |
---|
| 513 | %------------------------------------------------------------------------ |
---|
| 514 | % --- Executes on button press in CheckCiv1. |
---|
| 515 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
| 516 | %------------------------------------------------------------------------ |
---|
| 517 | update_CivOptions(handles,0) |
---|
| 518 | |
---|
| 519 | %------------------------------------------------------------------------ |
---|
| 520 | % --- Executes on button press in CheckFix1. |
---|
| 521 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
| 522 | %------------------------------------------------------------------------ |
---|
| 523 | update_CivOptions(handles,0) |
---|
| 524 | |
---|
| 525 | %------------------------------------------------------------------------ |
---|
| 526 | % --- Executes on button press in CheckPatch1. |
---|
| 527 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
| 528 | %------------------------------------------------------------------------ |
---|
| 529 | update_CivOptions(handles,0) |
---|
| 530 | |
---|
| 531 | %------------------------------------------------------------------------ |
---|
| 532 | % --- Executes on button press in CheckCiv2. |
---|
| 533 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
| 534 | %------------------------------------------------------------------------ |
---|
| 535 | update_CivOptions(handles,0) |
---|
| 536 | |
---|
| 537 | %------------------------------------------------------------------------ |
---|
| 538 | % --- Executes on button press in CheckFix2. |
---|
| 539 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
| 540 | %------------------------------------------------------------------------ |
---|
| 541 | update_CivOptions(handles,0) |
---|
| 542 | |
---|
| 543 | %------------------------------------------------------------------------ |
---|
| 544 | % --- Executes on button press in CheckPatch2. |
---|
| 545 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
| 546 | %------------------------------------------------------------------------ |
---|
| 547 | update_CivOptions(handles,0) |
---|
| 548 | |
---|
| 549 | %------------------------------------------------------------------------ |
---|
| 550 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
| 551 | function update_CivOptions(handles,opening) |
---|
| 552 | %------------------------------------------------------------------------ |
---|
[851] | 553 | if opening>0 |
---|
| 554 | set(handles.CheckCiv2,'UserData',opening)% store the info on the current status of the civ processing |
---|
| 555 | end |
---|
[597] | 556 | checkbox=zeros(1,6); |
---|
| 557 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
| 558 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
| 559 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
| 560 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
| 561 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
| 562 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
| 563 | if opening==0 |
---|
| 564 | errormsg=find_netcpair_civ(handles,1); % select the available netcdf files |
---|
| 565 | if ~isempty(errormsg) |
---|
| 566 | msgbox_uvmat('ERROR',errormsg) |
---|
| 567 | end |
---|
| 568 | end |
---|
[851] | 569 | if max(checkbox(4:6))>0% case of civ2 pair choice needed |
---|
[597] | 570 | set(handles.TitlePairCiv2,'Visible','on') |
---|
| 571 | set(handles.ListPairCiv2,'Visible','on') |
---|
| 572 | if ~opening |
---|
| 573 | errormsg=find_netcpair_civ(handles,2); % select the available netcdf files |
---|
| 574 | if ~isempty(errormsg) |
---|
| 575 | msgbox_uvmat('ERROR',errormsg) |
---|
| 576 | end |
---|
| 577 | end |
---|
| 578 | else |
---|
| 579 | set(handles.ListPairCiv2,'Visible','off') |
---|
| 580 | end |
---|
[862] | 581 | hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' |
---|
| 582 | hhseries=guidata(hseries); %handles of the elements in 'series' |
---|
| 583 | InputTable=get(hhseries.InputTable,'Data'); |
---|
| 584 | if size(InputTable,1)>=1 && strcmp(InputTable{1,5},'.nc') && max(checkbox(1:3))==0 %&& get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 |
---|
[855] | 585 | set(handles.CheckCiv3,'Visible','on') |
---|
[851] | 586 | else |
---|
[855] | 587 | set(handles.CheckCiv3,'Visible','off') |
---|
[851] | 588 | end |
---|
| 589 | |
---|
| 590 | %% set the visibility of the different panels |
---|
[597] | 591 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
| 592 | for ilist=1:length(options) |
---|
| 593 | if checkbox(ilist) |
---|
| 594 | set(handles.(options{ilist}),'Visible','on') |
---|
| 595 | else |
---|
| 596 | set(handles.(options{ilist}),'Visible','off') |
---|
| 597 | end |
---|
| 598 | end |
---|
| 599 | |
---|
| 600 | %------------------------------------------------------------------------ |
---|
| 601 | % --- Executes on button press in OK: processing on local computer |
---|
| 602 | function OK_Callback(hObject, eventdata, handles) |
---|
| 603 | %------------------------------------------------------------------------ |
---|
| 604 | |
---|
[855] | 605 | ActionInput=read_GUI(handles.civ_input);% read the infos on the GUI civ_input |
---|
[851] | 606 | |
---|
[855] | 607 | %% correct input inconsistencies |
---|
[851] | 608 | if isfield(ActionInput,'Civ1') |
---|
| 609 | checkeven=(mod(ActionInput.Civ1.CorrBoxSize,2)==0); |
---|
| 610 | ActionInput.Civ1.CorrBoxSize(checkeven)=ActionInput.Civ1.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
[1148] | 611 | ActionInput.Civ1.SearchBoxSize(1:2)=max(ActionInput.Civ1.SearchBoxSize(1:2),ActionInput.Civ1.CorrBoxSize(1:2)+8);% insure that the search box size is large enough |
---|
[851] | 612 | checkeven=(mod(ActionInput.Civ1.SearchBoxSize,2)==0); |
---|
| 613 | ActionInput.Civ1.SearchBoxSize(checkeven)=ActionInput.Civ1.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
| 614 | end |
---|
| 615 | if isfield(ActionInput,'Civ2') |
---|
| 616 | checkeven=(mod(ActionInput.Civ2.CorrBoxSize,2)==0); |
---|
| 617 | ActionInput.Civ2.CorrBoxSize(checkeven)=ActionInput.Civ2.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
[862] | 618 | ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+4); |
---|
[851] | 619 | checkeven=(mod(ActionInput.Civ2.SearchBoxSize,2)==0); |
---|
| 620 | ActionInput.Civ2.SearchBoxSize(checkeven)=ActionInput.Civ2.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
| 621 | end |
---|
| 622 | |
---|
[855] | 623 | %% correct mask or grid name for Windows system (replace '\' by '/') |
---|
| 624 | if isfield(ActionInput,'Civ1') |
---|
| 625 | if isfield(ActionInput.Civ1,'Mask') |
---|
| 626 | ActionInput.Civ1.Mask=regexprep(ActionInput.Civ1.Mask,'\','/'); |
---|
[822] | 627 | end |
---|
[855] | 628 | if isfield(ActionInput.Civ1,'Grid') |
---|
| 629 | ActionInput.Civ1.Grid=regexprep(ActionInput.Civ1.Grid,'\','/'); |
---|
[822] | 630 | end |
---|
| 631 | end |
---|
[855] | 632 | if isfield(ActionInput,'Civ2') |
---|
| 633 | if isfield(ActionInput.Civ2,'Mask') |
---|
| 634 | ActionInput.Civ2.Mask=regexprep(ActionInput.Civ2.Mask,'\','/'); |
---|
[822] | 635 | end |
---|
[855] | 636 | if isfield(ActionInput.Civ2,'Grid') |
---|
| 637 | ActionInput.Civ2.Grid=regexprep(ActionInput.Civ2.Grid,'\','/'); |
---|
[822] | 638 | end |
---|
| 639 | end |
---|
[855] | 640 | |
---|
| 641 | %% exit the GUI and close it |
---|
| 642 | handles.output.ActionInput=ActionInput; |
---|
[597] | 643 | guidata(hObject, handles);% Update handles structure |
---|
[598] | 644 | uiresume(handles.civ_input); |
---|
[597] | 645 | |
---|
| 646 | |
---|
| 647 | %------------------------------------------------------------------------ |
---|
| 648 | % --- Executes on button press in ListCompareMode. |
---|
| 649 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
| 650 | %------------------------------------------------------------------------ |
---|
| 651 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
| 652 | option=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
[645] | 653 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 654 | SeriesData=get(hseries,'UserData'); |
---|
| 655 | check_nc=strcmp(SeriesData.FileType{1},'.nc'); |
---|
| 656 | ImageType=SeriesData.FileType(2:end); |
---|
| 657 | if check_nc |
---|
| 658 | ImageType=SeriesData.FileType(2:end); |
---|
| 659 | else |
---|
| 660 | ImageType=SeriesData.FileType; |
---|
| 661 | end |
---|
| 662 | hhseries=guidata(hseries); |
---|
| 663 | InputTable=get(hhseries.InputTable,'Data'); |
---|
| 664 | OriginIndex='off'; |
---|
| 665 | PairIndices='off'; |
---|
[597] | 666 | switch option |
---|
| 667 | case 'PIV' |
---|
[1020] | 668 | PairIndices='on';% needs to define index pairs for PIV |
---|
[1148] | 669 | % case 'PIV volume' |
---|
| 670 | % PairIndices='on';% needs to define index pairs for PIV |
---|
| 671 | % set(handles.ListPairMode,'Value',1) |
---|
| 672 | % set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
| 673 | % ListPairMode_Callback(hObject, eventdata, handles) |
---|
[645] | 674 | case 'displacement' |
---|
| 675 | OriginIndex='on';%define a frame origin for displacement |
---|
[597] | 676 | end |
---|
[645] | 677 | set(handles.num_OriginIndex,'Visible',OriginIndex) |
---|
| 678 | set(handles.OriginIndex_title,'Visible',OriginIndex) |
---|
[1020] | 679 | set(handles.CheckRefFile,'Visible',OriginIndex) |
---|
| 680 | set(handles.RefFile,'Visible',OriginIndex) |
---|
[645] | 681 | set(handles.PairIndices,'Visible',PairIndices) |
---|
[1020] | 682 | ListPairMode_Callback(hObject,eventdata,handles) |
---|
| 683 | if strcmp(OriginIndex,'on') |
---|
| 684 | set(handles.CheckRefFile,'Value',1) |
---|
| 685 | CheckRefFile_Callback(hObject,eventdata,handles) |
---|
| 686 | end |
---|
[645] | 687 | |
---|
[597] | 688 | |
---|
| 689 | |
---|
| 690 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 691 | % Callbacks in the uipanel Pair Indices |
---|
| 692 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 693 | %------------------------------------------------------------------------ |
---|
| 694 | % --- Executes on button press in ListPairMode. |
---|
| 695 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
| 696 | %------------------------------------------------------------------------ |
---|
| 697 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 698 | val=get(handles.ListCompareMode,'Value'); |
---|
| 699 | compare=compare_list{val}; |
---|
| 700 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
[1020] | 701 | mode_selected='displacement'; |
---|
[597] | 702 | else |
---|
| 703 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 704 | if ischar(mode_list) |
---|
| 705 | mode_list={mode_list}; |
---|
[1018] | 706 | end |
---|
| 707 | mode_value=get(handles.ListPairMode,'Value'); |
---|
| 708 | if isempty(mode_value) |
---|
| 709 | mode_value=1; |
---|
[597] | 710 | end |
---|
[1020] | 711 | mode_selected=mode_list{mode_value}; |
---|
[597] | 712 | end |
---|
| 713 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
[599] | 714 | CivInputData=get(handles.civ_input,'UserData'); |
---|
[597] | 715 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
| 716 | checkframe=strcmp(TimeUnit,'frame'); |
---|
[599] | 717 | time=CivInputData.Time; |
---|
| 718 | siztime=size(CivInputData.Time); |
---|
[609] | 719 | nbfield=siztime(1)-1; |
---|
| 720 | nbfield2=siztime(2)-1; |
---|
[883] | 721 | %indchosen=1; %%first pair selected by default |
---|
[597] | 722 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
| 723 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
[1020] | 724 | if isequal(mode_selected,'pair j1-j2') |
---|
[597] | 725 | dt=1; |
---|
| 726 | index=0; |
---|
| 727 | numlist_a=[]; |
---|
| 728 | numlist_B=[]; |
---|
| 729 | %get all the time intervals in bursts |
---|
| 730 | displ_dt=1;%default |
---|
| 731 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
| 732 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 733 | for numod_b=(numod_a+1):nbfield2 |
---|
| 734 | index=index+1; |
---|
| 735 | numlist_a(index)=numod_a; |
---|
| 736 | numlist_b(index)=numod_b; |
---|
[932] | 737 | if size(time,2)>1 && ~checkframe && size(CivInputData.Time,1)>ref_i && size(CivInputData.Time,2)>numod_b |
---|
[599] | 738 | 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] | 739 | displ_dt(index)=dt(numod_a,numod_b); |
---|
| 740 | else |
---|
| 741 | displ_dt(index)=1; |
---|
| 742 | end |
---|
| 743 | end |
---|
| 744 | end |
---|
| 745 | [dtsort,indsort]=sort(displ_dt); |
---|
| 746 | enable_j(handles, 'off') |
---|
[1020] | 747 | elseif isequal(mode_selected,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
[597] | 748 | enable_j(handles, 'on') |
---|
[1020] | 749 | elseif isequal(mode_selected,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
[597] | 750 | enable_i(handles, 'on') |
---|
| 751 | if nbfield2 > 1 |
---|
| 752 | enable_j(handles, 'on') |
---|
| 753 | else |
---|
| 754 | enable_j(handles, 'off') |
---|
| 755 | end |
---|
[1020] | 756 | elseif isequal(mode_selected,'displacement')%the pairs have the same indices |
---|
[597] | 757 | if nbfield > 1 || nbfield==0 |
---|
| 758 | enable_i(handles, 'on') |
---|
| 759 | else |
---|
| 760 | enable_j(handles, 'off') |
---|
| 761 | end |
---|
| 762 | if nbfield2 > 1 |
---|
| 763 | enable_j(handles, 'on') |
---|
| 764 | else |
---|
| 765 | enable_j(handles, 'off') |
---|
| 766 | end |
---|
| 767 | end |
---|
| 768 | errormsg=find_netcpair_civ( handles,1); |
---|
[1033] | 769 | if ~isempty(errormsg) |
---|
[597] | 770 | msgbox_uvmat('ERROR',errormsg) |
---|
[1033] | 771 | end |
---|
[597] | 772 | |
---|
[1033] | 773 | %------------------------------------------------------------------------ |
---|
[597] | 774 | function enable_i(handles, state) |
---|
| 775 | set(handles.itext,'Visible',state) |
---|
[645] | 776 | set(handles.MaxIndex_i,'Visible',state) |
---|
[597] | 777 | set(handles.ref_i,'Visible',state) |
---|
| 778 | |
---|
[1033] | 779 | %------------------------------------------------------------------------ |
---|
[597] | 780 | function enable_j(handles, state) |
---|
| 781 | set(handles.jtext,'Visible',state) |
---|
[645] | 782 | set(handles.MinIndex_j,'Visible',state) |
---|
| 783 | set(handles.MaxIndex_j,'Visible',state) |
---|
[597] | 784 | set(handles.ref_j,'Visible',state) |
---|
| 785 | |
---|
| 786 | %------------------------------------------------------------------------ |
---|
| 787 | % --- Executes on selection change in ListPairCiv1. |
---|
| 788 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
| 789 | %------------------------------------------------------------------------ |
---|
| 790 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
[1156] | 791 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ1 by default |
---|
| 792 | ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
[597] | 793 | |
---|
| 794 | %------------------------------------------------------------------------ |
---|
| 795 | % --- Executes on selection change in ListPairCiv2. |
---|
| 796 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
| 797 | %------------------------------------------------------------------------ |
---|
| 798 | |
---|
| 799 | %------------------------------------------------------------------------ |
---|
| 800 | function ref_i_Callback(hObject, eventdata, handles) |
---|
| 801 | %------------------------------------------------------------------------ |
---|
| 802 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 803 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[1020] | 804 | mode_selected=mode_list{mode_value}; |
---|
[597] | 805 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
[1020] | 806 | if isequal(mode_selected,'series(Di)') || ...% we do patch2 only |
---|
[597] | 807 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
| 808 | errormsg=find_netcpair_civ( handles,2); |
---|
| 809 | end |
---|
[851] | 810 | if isempty(errormsg) |
---|
| 811 | set(handles.ref_i,'BackgroundColor',[1 1 1]) |
---|
[856] | 812 | set(handles.ref_j,'BackgroundColor',[1 1 1]) |
---|
[851] | 813 | else |
---|
[597] | 814 | msgbox_uvmat('ERROR',errormsg) |
---|
| 815 | end |
---|
| 816 | |
---|
[851] | 817 | function ref_i_KeyPressFcn(hObject, eventdata, handles) |
---|
| 818 | set(hObject,'BackgroundColor',[1 0 1]) |
---|
| 819 | |
---|
| 820 | % %------------------------------------------------------------------------ |
---|
[1020] | 821 | |
---|
[597] | 822 | function errormsg=find_netcpair_civ(handles,index) |
---|
| 823 | %------------------------------------------------------------------------ |
---|
| 824 | set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock) |
---|
| 825 | |
---|
| 826 | %% initialisation |
---|
| 827 | errormsg=''; |
---|
[603] | 828 | CivInputData=get(handles.civ_input,'UserData'); |
---|
[597] | 829 | compare_list=get(handles.ListCompareMode,'String'); |
---|
| 830 | val=get(handles.ListCompareMode,'Value'); |
---|
| 831 | compare=compare_list{val}; |
---|
[1020] | 832 | mode_selected='displacement'; |
---|
[880] | 833 | if ~strcmp(compare,'displacement')%||strcmp(compare,'shift') |
---|
| 834 | |
---|
[597] | 835 | mode_list=get(handles.ListPairMode,'String'); |
---|
| 836 | mode_value=get(handles.ListPairMode,'Value'); |
---|
[1018] | 837 | if isempty(mode_value) |
---|
| 838 | mode_value=1; |
---|
| 839 | end |
---|
[597] | 840 | if isempty(mode_list) |
---|
| 841 | return |
---|
| 842 | end |
---|
[1020] | 843 | mode_selected=mode_list{mode_value}; |
---|
[597] | 844 | end |
---|
[603] | 845 | nom_type_ima=CivInputData.NomTypeIma; |
---|
[881] | 846 | menu_pair=get(handles.ListPairCiv1,'String');%previous menu of ListPairCiv1 |
---|
| 847 | PairCiv1Init=menu_pair{get(handles.ListPairCiv1,'Value')};%previous choice of pair |
---|
| 848 | menu_pair=get(handles.ListPairCiv2,'String');%previous menu of ListPairCiv1 |
---|
| 849 | PairCiv2Init=menu_pair{get(handles.ListPairCiv2,'Value')};%previous choice of pair |
---|
[597] | 850 | |
---|
| 851 | %% reads .nc subdirectoy and image numbers from the interface |
---|
[637] | 852 | %SubDirImages=get(handles.Civ1_ImageA,'String'); |
---|
[609] | 853 | %TODO: determine |
---|
[637] | 854 | %subdir_civ1=[SubDirImages get(handles.Civ1_ImageB,'String')];%subdirectory subdir_civ1 for the netcdf data |
---|
| 855 | %subdir_civ2=[SubDirImages get(handles.Civ2_ImageA,'String')];%subdirectory subdir_civ2 for the netcdf data |
---|
[597] | 856 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
| 857 | ref_j=[]; |
---|
[1020] | 858 | if isequal(mode_selected,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
[597] | 859 | ref_j=0; |
---|
| 860 | elseif strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 861 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
| 862 | end |
---|
| 863 | if isempty(ref_j) |
---|
| 864 | ref_j=1; |
---|
| 865 | end |
---|
[609] | 866 | CivInputData=get(handles.civ_input,'UserData'); |
---|
[597] | 867 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
[633] | 868 | Time=CivInputData.Time; |
---|
[597] | 869 | checkframe=strcmp(TimeUnit,'frame'); |
---|
| 870 | |
---|
| 871 | %% case with no Civ1 operation, netcdf files need to exist for reading |
---|
| 872 | displ_pair={''}; |
---|
[609] | 873 | nbpair=200;%default |
---|
[597] | 874 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
| 875 | |
---|
| 876 | %% determine the menu display in .ListPairCiv1 |
---|
[1020] | 877 | switch mode_selected |
---|
[774] | 878 | case 'series(Di)' |
---|
[597] | 879 | for ipair=1:nbpair |
---|
| 880 | if select(ipair) |
---|
| 881 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[883] | 882 | displ_pair_dt{ipair}=displ_pair{ipair}; |
---|
[774] | 883 | if ~checkframe |
---|
| 884 | 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 |
---|
| 885 | 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 |
---|
[883] | 886 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
[774] | 887 | end |
---|
[597] | 888 | else |
---|
[635] | 889 | dt=ipair/1000; |
---|
[883] | 890 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(ipair)]; |
---|
[774] | 891 | end |
---|
[597] | 892 | else |
---|
[883] | 893 | displ_pair{ipair}='...'; |
---|
| 894 | displ_pair_dt{ipair}='...'; %pair not displayed in the menu |
---|
[597] | 895 | end |
---|
| 896 | end |
---|
[774] | 897 | case 'series(Dj)' |
---|
[597] | 898 | for ipair=1:nbpair |
---|
| 899 | if select(ipair) |
---|
| 900 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
[883] | 901 | displ_pair_dt{ipair}=displ_pair{ipair}; |
---|
[774] | 902 | if ~checkframe |
---|
| 903 | 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 |
---|
| 904 | 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 |
---|
[883] | 905 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
[774] | 906 | end |
---|
[635] | 907 | else |
---|
| 908 | dt=ipair/1000; |
---|
[883] | 909 | displ_pair_dt{ipair}=[displ_pair_dt{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
[774] | 910 | end |
---|
[597] | 911 | else |
---|
| 912 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
[883] | 913 | displ_pair_dt{ipair}='...'; %pair not displayed in the menu |
---|
[597] | 914 | end |
---|
| 915 | end |
---|
[774] | 916 | case 'pair j1-j2'%case of pairs |
---|
[776] | 917 | MinIndex_j=str2num(get(handles.MinIndex_j,'String')); |
---|
| 918 | MaxIndex_j=str2num(get(handles.MaxIndex_j,'String')); |
---|
[774] | 919 | index_pair=0; |
---|
| 920 | %get all the Time intervals in bursts |
---|
[918] | 921 | displ_pair_dt=''; |
---|
[774] | 922 | for numod_a=MinIndex_j:MaxIndex_j-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
| 923 | for numod_b=(numod_a+1):MaxIndex_j |
---|
| 924 | index_pair=index_pair+1; |
---|
| 925 | displ_pair{index_pair}=['j= ' num2stra(numod_a,nom_type_ima) '-' num2stra(numod_b,nom_type_ima)]; |
---|
[884] | 926 | displ_pair_dt{index_pair}=displ_pair{index_pair}; |
---|
[774] | 927 | dt(index_pair)=numod_b-numod_a;%default dt |
---|
| 928 | if size(Time,1)>ref_i && size(Time,2)>numod_b % && ~checkframe |
---|
| 929 | dt(index_pair)=Time(ref_i+1,numod_b+1)-Time(ref_i+1,numod_a+1);% Time interval dt |
---|
[883] | 930 | displ_pair_dt{index_pair}=[displ_pair_dt{index_pair} ' :dt= ' num2str(dt(index_pair)*1000)]; |
---|
[774] | 931 | end |
---|
[597] | 932 | end |
---|
[774] | 933 | |
---|
[597] | 934 | end |
---|
[918] | 935 | if index_pair ~=0 |
---|
[774] | 936 | [tild,indsort]=sort(dt); |
---|
| 937 | displ_pair=displ_pair(indsort); |
---|
[883] | 938 | displ_pair_dt=displ_pair_dt(indsort); |
---|
[918] | 939 | end |
---|
[774] | 940 | case 'displacement' |
---|
[1033] | 941 | % displ_pair={'Di=Dj=0'}; |
---|
| 942 | % displ_pair_dt={'Di=Dj=0'}; |
---|
| 943 | set(handles.PairIndices,'Visible','off') |
---|
[597] | 944 | end |
---|
[1033] | 945 | if index==1 && ~strcmp(mode_selected,'displacement') |
---|
[883] | 946 | set(handles.ListPairCiv1,'String',displ_pair_dt'); |
---|
[597] | 947 | end |
---|
| 948 | |
---|
[758] | 949 | %% determine the default selection in the pair menu for Civ1 |
---|
[881] | 950 | %ichoice=find(select,1);% index of first selected pair |
---|
| 951 | %if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
[883] | 952 | end_pair=regexp(PairCiv1Init,' :dt='); |
---|
| 953 | if ~isempty(end_pair) |
---|
| 954 | PairCiv1Init=PairCiv1Init(1:end_pair-1); |
---|
| 955 | end |
---|
[881] | 956 | ichoice=find(strcmp(PairCiv1Init,displ_pair'),1); |
---|
[880] | 957 | if ~isempty(ichoice) |
---|
[597] | 958 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
[880] | 959 | else |
---|
| 960 | set(handles.ListPairCiv1,'Value',1) |
---|
[597] | 961 | end |
---|
[758] | 962 | |
---|
| 963 | %% determine the default selection in the pair menu for Civ2 |
---|
[1033] | 964 | if ~strcmp(mode_selected,'displacement') |
---|
[758] | 965 | if strcmp(get(handles.ListPairCiv2,'Visible'),'on') |
---|
[883] | 966 | end_pair=regexp(PairCiv2Init,' :dt='); |
---|
| 967 | if ~isempty(end_pair) |
---|
| 968 | PairCiv2Init=PairCiv2Init(1:end_pair-1); |
---|
| 969 | end |
---|
[881] | 970 | ichoice=find(strcmp(PairCiv2Init,displ_pair'),1); |
---|
| 971 | if ~isempty(ichoice) |
---|
| 972 | set(handles.ListPairCiv2,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
| 973 | else |
---|
| 974 | set(handles.ListPairCiv2,'Value',1) |
---|
[597] | 975 | end |
---|
[758] | 976 | else |
---|
| 977 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))% initiate the choice of Civ2 as a reproduction of if civ1 |
---|
[597] | 978 | end |
---|
[883] | 979 | set(handles.ListPairCiv2,'String',displ_pair_dt'); |
---|
[1033] | 980 | end |
---|
[758] | 981 | set(gcf,'Pointer','arrow')% Indicate that the process is finished |
---|
[597] | 982 | |
---|
| 983 | |
---|
| 984 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 985 | % Callbacks in the uipanel Reference Indices |
---|
| 986 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 987 | %------------------------------------------------------------------------ |
---|
[645] | 988 | function MinIndex_i_Callback(hObject, eventdata, handles) |
---|
[597] | 989 | %------------------------------------------------------------------------ |
---|
[645] | 990 | first_i=str2double(get(handles.MinIndex_i,'String')); |
---|
[597] | 991 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
| 992 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
| 993 | |
---|
[776] | 994 | % %------------------------------------------------------------------------ |
---|
| 995 | % function MinIndex_j_Callback(hObject, eventdata, handles) |
---|
| 996 | % %------------------------------------------------------------------------ |
---|
| 997 | % first_j=str2num(get(handles.MinIndex_j,'String')); |
---|
| 998 | % set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
| 999 | % ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
[597] | 1000 | |
---|
| 1001 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 1002 | % Callbacks in the uipanel Civ1 |
---|
| 1003 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 1004 | %------------------------------------------------------------------------ |
---|
| 1005 | % --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 |
---|
| 1006 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
| 1007 | %------------------------------------------------------------------------ |
---|
| 1008 | %determine pair numbers |
---|
| 1009 | if strcmp(get(handles.num_UMin,'Visible'),'off') |
---|
| 1010 | set(handles.u_title,'Visible','on') |
---|
| 1011 | set(handles.v_title,'Visible','on') |
---|
| 1012 | set(handles.num_UMin,'Visible','on') |
---|
| 1013 | set(handles.num_UMax,'Visible','on') |
---|
| 1014 | set(handles.num_VMin,'Visible','on') |
---|
| 1015 | set(handles.num_VMax,'Visible','on') |
---|
[854] | 1016 | %set(handles.CoordUnit,'Visible','on') |
---|
| 1017 | %set(handles.TimeUnit,'Visible','on') |
---|
| 1018 | %set(handles.slash_title,'Visible','on') |
---|
[597] | 1019 | set(handles.min_title,'Visible','on') |
---|
| 1020 | set(handles.max_title,'Visible','on') |
---|
| 1021 | set(handles.unit_title,'Visible','on') |
---|
| 1022 | else |
---|
| 1023 | get_search_range(hObject, eventdata, handles) |
---|
| 1024 | end |
---|
| 1025 | |
---|
| 1026 | %------------------------------------------------------------------------ |
---|
| 1027 | % --- determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift |
---|
| 1028 | function get_search_range(hObject, eventdata, handles) |
---|
| 1029 | %------------------------------------------------------------------------ |
---|
| 1030 | param_civ1=read_GUI(handles.Civ1); |
---|
| 1031 | umin=param_civ1.UMin; |
---|
| 1032 | umax=param_civ1.UMax; |
---|
| 1033 | vmin=param_civ1.VMin; |
---|
| 1034 | vmax=param_civ1.VMax; |
---|
| 1035 | %switch min_title and max_title in case of error |
---|
| 1036 | if umax<=umin |
---|
| 1037 | umin_old=umin; |
---|
| 1038 | umin=umax; |
---|
| 1039 | umax=umin_old; |
---|
| 1040 | set(handles.num_UMin,'String', num2str(umin)) |
---|
| 1041 | set(handles.num_UMax,'String', num2str(umax)) |
---|
| 1042 | end |
---|
| 1043 | if vmax<=vmin |
---|
| 1044 | vmin_old=vmin; |
---|
| 1045 | vmin=vmax; |
---|
| 1046 | vmax=vmin_old; |
---|
| 1047 | set(handles.num_VMin,'String', num2str(vmin)) |
---|
| 1048 | set(handles.num_VMax,'String', num2str(vmax)) |
---|
| 1049 | end |
---|
| 1050 | if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax)) |
---|
| 1051 | shiftx=round((umin+umax)/2); |
---|
| 1052 | shifty=round((vmin+vmax)/2); |
---|
[854] | 1053 | isx=(umax+2-shiftx)*2+param_civ1.CorrBoxSize(1); |
---|
[597] | 1054 | isx=2*ceil(isx/2)+1; |
---|
[854] | 1055 | isy=(vmax+2-shifty)*2+param_civ1.CorrBoxSize(2); |
---|
[597] | 1056 | isy=2*ceil(isy/2)+1; |
---|
| 1057 | set(handles.num_SearchBoxShift_1,'String',num2str(shiftx)); |
---|
| 1058 | set(handles.num_SearchBoxShift_2,'String',num2str(shifty)); |
---|
| 1059 | set(handles.num_SearchBoxSize_1,'String',num2str(isx)); |
---|
| 1060 | set(handles.num_SearchBoxSize_2,'String',num2str(isy)); |
---|
| 1061 | end |
---|
| 1062 | |
---|
[851] | 1063 | %------------------------------------------------------------------------ |
---|
[856] | 1064 | % --- Executes on selection in menu CorrSmooth. |
---|
[851] | 1065 | function num_CorrSmooth_Callback(hObject, eventdata, handles) |
---|
[873] | 1066 | set(handles.ConfigSource,'String','NEW') |
---|
[856] | 1067 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
[851] | 1068 | %------------------------------------------------------------------------ |
---|
| 1069 | |
---|
[859] | 1070 | % --- Executes on button press in CheckDeformation. |
---|
| 1071 | function CheckDeformation_Callback(hObject, eventdata, handles) |
---|
[862] | 1072 | set(handles.ConfigSource,'String','NEW') |
---|
[859] | 1073 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
[885] | 1074 | handles_CoorSmooth=findobj(get(handles.Civ2,'children'),'Tag','num_CorrSmooth'); |
---|
| 1075 | if get(handles.CheckDeformation,'Value') |
---|
| 1076 | set(handles_CoorSmooth,'Visible','off') |
---|
[883] | 1077 | else |
---|
[885] | 1078 | set(handles_CoorSmooth,'Visible','on') |
---|
[883] | 1079 | end |
---|
[859] | 1080 | |
---|
[597] | 1081 | %------------------------------------------------------------------------ |
---|
| 1082 | % --- function called to look for grid files |
---|
| 1083 | function [nbslice, flag_grid]=get_grid(filebase,handles) |
---|
| 1084 | %------------------------------------------------------------------------ |
---|
| 1085 | flag_grid=0;%default |
---|
| 1086 | nbslice=1; |
---|
| 1087 | [Path,Name]=fileparts(filebase); |
---|
| 1088 | currentdir=pwd; |
---|
| 1089 | cd(Path);%move in the dir of the root name filebase |
---|
| 1090 | gridfiles=dir([Name '_*grid_*.grid']);%look for grid files |
---|
| 1091 | cd(currentdir);%come back to the current working directory |
---|
| 1092 | if ~isempty(gridfiles) |
---|
| 1093 | flag_grid=1; |
---|
| 1094 | gridname=gridfiles(1).name;% take the first grid file in the list |
---|
| 1095 | [Path2,Name,ext]=fileparts(gridname); |
---|
| 1096 | Namedouble=double(Name); |
---|
| 1097 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 1098 | ind_grid=findstr('grid',Name); |
---|
| 1099 | i=ind_grid-1; |
---|
| 1100 | while val(i)==0 && i>0 |
---|
| 1101 | i=i-1; |
---|
| 1102 | end |
---|
| 1103 | nbslice=str2double(Name(i+1:ind_grid-1)); |
---|
| 1104 | if ~isnan(nbslice) && Name(i)=='_' |
---|
| 1105 | flag_grid=1; |
---|
| 1106 | else |
---|
| 1107 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
| 1108 | return |
---|
| 1109 | nbslice=1; |
---|
| 1110 | end |
---|
| 1111 | end |
---|
| 1112 | |
---|
| 1113 | %------------------------------------------------------------------------ |
---|
| 1114 | % --- transform numbers to letters |
---|
| 1115 | function str=num2stra(num,nom_type) |
---|
| 1116 | %------------------------------------------------------------------------ |
---|
| 1117 | if isempty(nom_type) |
---|
| 1118 | str=''; |
---|
| 1119 | elseif strcmp(nom_type(end),'a') |
---|
| 1120 | str=char(96+num); |
---|
| 1121 | elseif strcmp(nom_type(end),'A') |
---|
| 1122 | str=char(96+num); |
---|
| 1123 | elseif isempty(nom_type(2:end))%a single index |
---|
| 1124 | str=''; |
---|
| 1125 | else |
---|
| 1126 | str=num2str(num); |
---|
| 1127 | end |
---|
| 1128 | |
---|
| 1129 | % %------------------------------------------------------------------------ |
---|
| 1130 | % % --- Executes on button press in ListSubdirCiv1. |
---|
| 1131 | % function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
| 1132 | % %------------------------------------------------------------------------ |
---|
| 1133 | % list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
| 1134 | % val=get(handles.ListSubdirCiv1,'Value'); |
---|
| 1135 | % SubDir=list_subdir_civ1{val}; |
---|
| 1136 | % if strcmp(SubDir,'new...') |
---|
| 1137 | % if get(handles.CheckCiv1,'Value') |
---|
| 1138 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
| 1139 | % else |
---|
| 1140 | % msgbox_uvmat('ERROR','select CheckCiv1 to perform a new civ_input operation') |
---|
| 1141 | % return |
---|
| 1142 | % end |
---|
| 1143 | % end |
---|
[604] | 1144 | % set(handles.Civ1_ImageB,'String',SubDir); |
---|
[597] | 1145 | % errormsg=find_netcpair_civ(handles,1); |
---|
| 1146 | % if ~isempty(errormsg) |
---|
| 1147 | % msgbox_uvmat('ERROR',errormsg) |
---|
| 1148 | % end |
---|
| 1149 | % |
---|
| 1150 | %------------------------------------------------------------------------ |
---|
| 1151 | % % --- Executes on button press in ListSubdirCiv2. |
---|
| 1152 | % function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
| 1153 | % %------------------------------------------------------------------------ |
---|
| 1154 | % list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
| 1155 | % val=get(handles.ListSubdirCiv2,'Value'); |
---|
| 1156 | % SubDir=list_subdir_civ2{val}; |
---|
| 1157 | % if strcmp(SubDir,'new...') |
---|
| 1158 | % if get(handles.CheckCiv2,'Value') |
---|
| 1159 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
| 1160 | % else |
---|
| 1161 | % msgbox_uvmat('ERROR','select CheckCiv2 to perform a new civ_input operation') |
---|
| 1162 | % return |
---|
| 1163 | % end |
---|
| 1164 | % end |
---|
[604] | 1165 | % set(handles.Civ2_ImageA,'String',SubDir); |
---|
[597] | 1166 | |
---|
| 1167 | %------------------------------------------------------------------------ |
---|
| 1168 | % --- Executes on button press in CheckGrid. |
---|
| 1169 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
| 1170 | %------------------------------------------------------------------------ |
---|
| 1171 | value=get(hObject,'Value'); |
---|
| 1172 | hparent=get(hObject,'parent');%handles of the parent panel |
---|
| 1173 | hchildren=get(hparent,'children'); |
---|
| 1174 | handle_txtbox=findobj(hchildren,'tag','Grid');% look for the grid name box in the same panel |
---|
| 1175 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 1176 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
| 1177 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 1178 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
| 1179 | testgrid=0; |
---|
| 1180 | filegrid=''; |
---|
| 1181 | if value |
---|
[665] | 1182 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 1183 | hhseries=guidata(hseries); |
---|
| 1184 | InputTable=get(hhseries.InputTable,'Data'); |
---|
| 1185 | ind_A=1;% line index of the (first) image series |
---|
| 1186 | if strcmp(InputTable{1,5},'.nc'); |
---|
| 1187 | ind_A=2; |
---|
| 1188 | end |
---|
| 1189 | filebase=InputTable{ind_A,1}; |
---|
[597] | 1190 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
| 1191 | if isequal(flag_grid,1) |
---|
| 1192 | filegrid=[num2str(nbslice) 'grid']; |
---|
| 1193 | testgrid=1; |
---|
| 1194 | else % browse for a grid |
---|
| 1195 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
| 1196 | if exist(filegrid,'file') |
---|
| 1197 | filebase=filegrid; |
---|
| 1198 | end |
---|
[665] | 1199 | filegrid = uigetfile_uvmat('pick a grid file .grid:',filebase,'.grid'); |
---|
[597] | 1200 | set(hObject,'UserData',filegrid);%store for future use |
---|
[665] | 1201 | if ~isempty(filegrid) |
---|
[597] | 1202 | testgrid=1; |
---|
[665] | 1203 | end |
---|
| 1204 | set(hObject,'UserData',filegrid);%store for future use |
---|
[597] | 1205 | end |
---|
| 1206 | end |
---|
| 1207 | if testgrid |
---|
| 1208 | set(handle_dx,'Visible','off'); |
---|
| 1209 | set(handle_dy,'Visible','off'); |
---|
| 1210 | set(handle_title_dy,'Visible','off'); |
---|
| 1211 | set(handle_title_dx,'Visible','off'); |
---|
| 1212 | set(handle_txtbox,'Visible','on') |
---|
| 1213 | set(handle_txtbox,'String',filegrid) |
---|
| 1214 | else |
---|
| 1215 | set(hObject,'Value',0); |
---|
| 1216 | set(handle_dx,'Visible','on'); |
---|
| 1217 | set(handle_dy,'Visible','on'); |
---|
| 1218 | set(handle_title_dy,'Visible','on'); |
---|
| 1219 | set(handle_title_dx,'Visible','on'); |
---|
| 1220 | set(handle_txtbox,'Visible','off') |
---|
| 1221 | end |
---|
| 1222 | |
---|
| 1223 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
| 1224 | PanelName=get(hparent,'tag'); |
---|
| 1225 | if strcmp(PanelName,'Civ1') |
---|
| 1226 | hchildren=get(handles.Civ2,'children'); |
---|
| 1227 | handle_checkbox=findobj(hchildren,'tag','CheckGrid'); |
---|
| 1228 | handle_txtbox=findobj(hchildren,'tag','Grid'); |
---|
| 1229 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
| 1230 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
| 1231 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
| 1232 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
| 1233 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
| 1234 | if testgrid |
---|
| 1235 | set(handle_checkbox,'Value',1); |
---|
| 1236 | set(handle_dx,'Visible','off'); |
---|
| 1237 | set(handle_dy,'Visible','off'); |
---|
| 1238 | set(handle_title_dx,'Visible','off'); |
---|
| 1239 | set(handle_title_dy,'Visible','off'); |
---|
| 1240 | set(handle_txtbox,'Visible','on') |
---|
| 1241 | set(handle_txtbox,'String',filegrid) |
---|
| 1242 | end |
---|
| 1243 | end |
---|
[873] | 1244 | set(handles.ConfigSource,'String','NEW') |
---|
[856] | 1245 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
[918] | 1246 | |
---|
[597] | 1247 | %------------------------------------------------------------------------ |
---|
| 1248 | % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) |
---|
| 1249 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1250 | %------------------------------------------------------------------------ |
---|
| 1251 | hparent=get(hObject,'parent'); |
---|
| 1252 | hchildren=get(hparent,'children'); |
---|
| 1253 | handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel |
---|
[1153] | 1254 | % handle_NbSlice=findobj(hchildren,'tag','num_NbSlice');% look for the mask name box in the same panel |
---|
[597] | 1255 | testmask=0; |
---|
[1153] | 1256 | if get(hObject,'Value')% if the checkbox is activated |
---|
[665] | 1257 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 1258 | hhseries=guidata(hseries); |
---|
| 1259 | InputTable=get(hhseries.InputTable,'Data'); |
---|
[1153] | 1260 | if strcmp(InputTable{1,5},'.nc') |
---|
| 1261 | ind_A=2;%case of nc file as input (for civ3), image in second line |
---|
| 1262 | else |
---|
| 1263 | ind_A=1;% line index of the (first) image series |
---|
[665] | 1264 | end |
---|
[1153] | 1265 | % browse for a mask |
---|
| 1266 | filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image'); |
---|
| 1267 | if ~isempty(filemask) |
---|
| 1268 | [FilePath,FileName,FileExt]=fileparts(filemask); |
---|
| 1269 | [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName FileExt]); |
---|
[1010] | 1270 | if strcmp(NomType,'_1') |
---|
[1153] | 1271 | NbSlice=i1_series(1,2,end); |
---|
| 1272 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
| 1273 | elseif ~strcmp(NomType,'*') |
---|
| 1274 | msgbox_uvmat('ERROR','multilevel masks must be labeled with a single index as _1,_2,...'); |
---|
| 1275 | return |
---|
[1010] | 1276 | end |
---|
[597] | 1277 | set(hObject,'UserData',filemask);%store for future use |
---|
[1153] | 1278 | testmask=1; |
---|
| 1279 | end |
---|
[597] | 1280 | end |
---|
| 1281 | if testmask |
---|
[851] | 1282 | set(handles.Mask,'Visible','on') |
---|
| 1283 | set(handles.Mask,'String',filemask) |
---|
[597] | 1284 | set(handles.CheckMask,'Value',1) |
---|
[1010] | 1285 | if strcmp(NomType,'_1') |
---|
| 1286 | set(handles.num_NbSlice,'Visible','on') |
---|
| 1287 | end |
---|
[597] | 1288 | else |
---|
| 1289 | set(hObject,'Value',0); |
---|
| 1290 | set(handle_txtbox,'Visible','off') |
---|
[1010] | 1291 | set(handles.num_NbSlice,'Visible','off') |
---|
[597] | 1292 | end |
---|
[873] | 1293 | set(handles.ConfigSource,'String','NEW') |
---|
| 1294 | set(handles.ConfigSource,'BackgroundColor',[1 0 1]) |
---|
[597] | 1295 | |
---|
[851] | 1296 | % %------------------------------------------------------------------------ |
---|
| 1297 | % % --- Executes on button press in get_gridpatch1. |
---|
| 1298 | % function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
| 1299 | % %------------------------------------------------------------------------ |
---|
| 1300 | % filebase=get(handles.RootPath,'String'); |
---|
| 1301 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1302 | % {'*.grid', ' (*.grid)'; |
---|
| 1303 | % '*.grid', '.grid files '; ... |
---|
| 1304 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 1305 | % 'Pick a file',filebase); |
---|
| 1306 | % filegrid=fullfile(PathName,FileName); |
---|
| 1307 | % set(handles.grid_patch1,'string',filegrid); |
---|
| 1308 | % set(hObject,'BackgroundColor',[1 0 1]) |
---|
[597] | 1309 | |
---|
| 1310 | %------------------------------------------------------------------------ |
---|
| 1311 | % --- STEREO Interp |
---|
| 1312 | 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) |
---|
| 1313 | %------------------------------------------------------------------------ |
---|
| 1314 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
| 1315 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
| 1316 | ' -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 |
---|
| 1317 | |
---|
| 1318 | % %------------------------------------------------------------------------ |
---|
| 1319 | % %--read images and convert them to the uint16 format used for PIV |
---|
| 1320 | % function A=read_image(filename,type_ima,num,movieobject) |
---|
| 1321 | % %------------------------------------------------------------------------ |
---|
| 1322 | % %num is the view number needed for an avi movie |
---|
| 1323 | % switch type_ima |
---|
| 1324 | % case 'movie' |
---|
| 1325 | % A=read(movieobject,num); |
---|
| 1326 | % case 'avi' |
---|
| 1327 | % mov=aviread(filename,num); |
---|
| 1328 | % A=frame2im(mov(1)); |
---|
| 1329 | % case 'multimage' |
---|
| 1330 | % A=imread(filename,num); |
---|
| 1331 | % case 'image' |
---|
| 1332 | % A=imread(filename); |
---|
| 1333 | % end |
---|
| 1334 | % siz=size(A); |
---|
| 1335 | % if length(siz)==3;%color images |
---|
| 1336 | % A=sum(double(A),3); |
---|
| 1337 | % A=uint16(A); |
---|
| 1338 | % end |
---|
| 1339 | |
---|
| 1340 | |
---|
| 1341 | %------------------------------------------------------------------------ |
---|
| 1342 | % --- Executes on button press in get_ref_fix1. |
---|
| 1343 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
| 1344 | %------------------------------------------------------------------------ |
---|
| 1345 | filebase=get(handles.RootPath,'String'); |
---|
| 1346 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1347 | {'*.nc', ' (*.nc)'; |
---|
| 1348 | '*.nc', 'netcdf files '; ... |
---|
| 1349 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1350 | 'Pick a file',filebase); |
---|
| 1351 | |
---|
| 1352 | fileinput=[PathName FileName]; |
---|
| 1353 | sizf=size(fileinput); |
---|
| 1354 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 1355 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 1356 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
| 1357 | ref.filebase=fullfile(Path,File); |
---|
| 1358 | % ref.num_a=stra2num(str_a); |
---|
| 1359 | % ref.num_b=stra2num(str_b); |
---|
| 1360 | % ref.num1=str2double(field_count); |
---|
| 1361 | % ref.num2=str2double(str2); |
---|
| 1362 | browse=[];%initialisation |
---|
| 1363 | if ~isequal(ref.ext,'.nc') |
---|
| 1364 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 1365 | return |
---|
| 1366 | end |
---|
| 1367 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 1368 | set(handles.ref_fix1,'UserData',ref) |
---|
| 1369 | menu_field{1}='civ1'; |
---|
| 1370 | Data=nc2struct(fileinput,[]); |
---|
| 1371 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 1372 | menu_field{2}='filter1'; |
---|
| 1373 | end |
---|
| 1374 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 1375 | menu_field{3}='civ2'; |
---|
| 1376 | end |
---|
| 1377 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
| 1378 | menu_field{4}='filter2'; |
---|
| 1379 | end |
---|
| 1380 | set(handles.field_ref1,'String',menu_field); |
---|
| 1381 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
| 1382 | set(handles.num_MinVel,'Value',2); |
---|
| 1383 | set(handles.num_MinVel,'String','1');%default threshold |
---|
| 1384 | set(handles.ref_fix1,'Enable','on') |
---|
| 1385 | |
---|
| 1386 | %------------------------------------------------------------------------ |
---|
| 1387 | % --- Executes on button press in get_ref_fix2. |
---|
| 1388 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
| 1389 | %------------------------------------------------------------------------ |
---|
| 1390 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
| 1391 | filebase=get(handles.RootPath,'String'); |
---|
| 1392 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1393 | {'*.nc', ' (*.nc)'; |
---|
| 1394 | '*.nc', 'netcdf files '; ... |
---|
| 1395 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1396 | 'Pick a file',filebase); |
---|
| 1397 | fileinput=[PathName FileName]; |
---|
| 1398 | sizf=size(fileinput); |
---|
| 1399 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
| 1400 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
| 1401 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
| 1402 | ref.filebase=fullfile(Path,File); |
---|
[692] | 1403 | % ref.num_a=stra2num(str_a); |
---|
| 1404 | % ref.num_b=stra2num(str_b); |
---|
| 1405 | % ref.num1=str2num(field_count); |
---|
| 1406 | % ref.num2=str2num(str2); |
---|
[597] | 1407 | browse=[];%initialisation |
---|
| 1408 | if ~isequal(ref.ext,'.nc') |
---|
| 1409 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
| 1410 | return |
---|
| 1411 | end |
---|
| 1412 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
| 1413 | set(handles.ref_fix2,'UserData',ref) |
---|
| 1414 | menu_field{1}='civ1'; |
---|
| 1415 | Data=nc2struct(fileinput,[]); |
---|
| 1416 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
| 1417 | menu_field{2}='filter1'; |
---|
| 1418 | end |
---|
| 1419 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
| 1420 | menu_field{3}='civ2'; |
---|
| 1421 | end |
---|
| 1422 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
| 1423 | menu_field{4}='filter2'; |
---|
| 1424 | end |
---|
| 1425 | set(handles.field_ref2,'String',menu_field); |
---|
| 1426 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
| 1427 | set(handles.num_MinVel,'Value',2); |
---|
| 1428 | set(handles.num_MinVel,'String','1');%default threshold |
---|
| 1429 | set(handles.ref_fix2,'Enable','on') |
---|
| 1430 | set(handles.ref_fix2,'Visible','on') |
---|
| 1431 | set(handles.field_ref2,'Visible','on') |
---|
| 1432 | else |
---|
| 1433 | set(handles.ref_fix2,'Visible','off') |
---|
| 1434 | set(handles.field_ref2,'Visible','off') |
---|
| 1435 | end |
---|
| 1436 | |
---|
| 1437 | %------------------------------------------------------------------------ |
---|
| 1438 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
| 1439 | %------------------------------------------------------------------------ |
---|
| 1440 | set(handles.num_MinVel,'Value',1); |
---|
| 1441 | set(handles.field_ref1,'Value',1) |
---|
| 1442 | set(handles.field_ref1,'String',{' '}) |
---|
| 1443 | set(handles.ref_fix1,'UserData',[]); |
---|
| 1444 | set(handles.ref_fix1,'String',''); |
---|
| 1445 | set(handles.thresh_vel1,'String','0'); |
---|
| 1446 | |
---|
| 1447 | %------------------------------------------------------------------------ |
---|
| 1448 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
| 1449 | %------------------------------------------------------------------------ |
---|
| 1450 | set(handles.num_MinVel,'Value',1); |
---|
| 1451 | set(handles.field_ref2,'Value',1) |
---|
| 1452 | set(handles.field_ref2,'String',{' '}) |
---|
| 1453 | set(handles.ref_fix2,'UserData',[]); |
---|
| 1454 | set(handles.ref_fix2,'String',''); |
---|
| 1455 | set(handles.num_MinVel,'String','0'); |
---|
| 1456 | |
---|
| 1457 | %------------------------------------------------------------------------ |
---|
| 1458 | % --- TO ABANDON Executes on button press in test_stereo1. |
---|
| 1459 | function CheckStereo_Callback(hObject, eventdata, handles) |
---|
| 1460 | %------------------------------------------------------------------------ |
---|
| 1461 | hparent=get(hObject,'parent'); |
---|
| 1462 | parent_tag=get(hparent,'Tag'); |
---|
| 1463 | hchildren=get(hparent,'children'); |
---|
| 1464 | handle_txtbox=findobj(hchildren,'tag','txt_Mask'); |
---|
| 1465 | if isequal(get(hObject,'Value'),0) |
---|
| 1466 | set(handles.num_SubDomainSize,'Visible','on') |
---|
| 1467 | set(handles.num_FieldSmooth,'Visible','on') |
---|
| 1468 | else |
---|
| 1469 | set(handles.num_SubDomainSize,'Visible','off') |
---|
| 1470 | set(handles.num_FieldSmooth,'Visible','off') |
---|
| 1471 | end |
---|
| 1472 | |
---|
| 1473 | % %------------------------------------------------------------------------ |
---|
| 1474 | % % --- Executes on button press in CheckStereo. |
---|
| 1475 | % function StereoCheck_Callback(hObject, eventdata, handles) |
---|
| 1476 | % %------------------------------------------------------------------------ |
---|
| 1477 | % if isequal(get(handles.CheckStereo,'Value'),0) |
---|
| 1478 | % set(handles.num_subdomainsize,'Visible','on') |
---|
| 1479 | % set(handles.num_FieldSmooth,'Visible','on') |
---|
| 1480 | % else |
---|
[651] | 1481 | |
---|
[597] | 1482 | % set(handles.num_subdomainsize,'Visible','off') |
---|
| 1483 | % set(handles.num_FieldSmooth,'Visible','off') |
---|
| 1484 | % end |
---|
| 1485 | |
---|
[774] | 1486 | |
---|
| 1487 | |
---|
| 1488 | %------------------------------------------------------------------------ |
---|
| 1489 | %----function introduced for the correlation window figure, activated by deleting this window |
---|
| 1490 | function closeview_field(gcbo,eventdata) |
---|
[597] | 1491 | %------------------------------------------------------------------------ |
---|
[774] | 1492 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 1493 | if ~isempty(hview_field) |
---|
| 1494 | delete(hview_field) |
---|
| 1495 | end |
---|
| 1496 | |
---|
| 1497 | %------------------------------------------------------------------------ |
---|
| 1498 | % --- Executes on button press in CheckThreshold. |
---|
| 1499 | function CheckThreshold_Callback(hObject, eventdata, handles) |
---|
| 1500 | %------------------------------------------------------------------------ |
---|
| 1501 | huipanel=get(hObject,'parent'); |
---|
| 1502 | obj(1)=findobj(huipanel,'Tag','num_MinIma'); |
---|
| 1503 | obj(2)=findobj(huipanel,'Tag','num_MaxIma'); |
---|
| 1504 | obj(3)=findobj(huipanel,'Tag','title_Threshold'); |
---|
| 1505 | if get(hObject,'Value') |
---|
| 1506 | set(obj,'Visible','on') |
---|
| 1507 | else |
---|
| 1508 | set(obj,'Visible','off') |
---|
| 1509 | end |
---|
[873] | 1510 | set(handles.ConfigSource,'String','NEW') |
---|
[856] | 1511 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
[774] | 1512 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 1513 | %%%%%%%%%%%%%% TEST functions |
---|
| 1514 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 1515 | %------------------------------------------------------------------------ |
---|
[597] | 1516 | % --- Executes on button press in TestCiv1: prepare the image correlation function |
---|
[774] | 1517 | % activated by mouse motion |
---|
[597] | 1518 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
| 1519 | %------------------------------------------------------------------------ |
---|
| 1520 | drawnow |
---|
| 1521 | if get(handles.TestCiv1,'Value') |
---|
[855] | 1522 | set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch |
---|
[873] | 1523 | set(handles.CheckFix1,'value',0)% desactivate next step |
---|
| 1524 | set(handles.CheckPatch1,'value',0)% desactivate next step |
---|
| 1525 | set(handles.CheckCiv2,'value',0)% desactivate next step |
---|
| 1526 | set(handles.CheckFix2,'value',0)% desactivate next step |
---|
| 1527 | set(handles.CheckPatch2,'value',0)% desactivate next step |
---|
| 1528 | update_CivOptions(handles,0) |
---|
[860] | 1529 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 1530 | Param=read_GUI(hseries); |
---|
| 1531 | Param.Action.RUN=1; |
---|
| 1532 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
[862] | 1533 | if isfield(Param.ActionInput,'Fix1') |
---|
| 1534 | Param.ActionInput=rmfield(Param.ActionInput,'Fix1'); |
---|
| 1535 | end |
---|
| 1536 | if isfield(Param.ActionInput,'Patch1') |
---|
| 1537 | Param.ActionInput=rmfield(Param.ActionInput,'Patch1'); |
---|
| 1538 | end |
---|
| 1539 | if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 |
---|
| 1540 | Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); |
---|
| 1541 | end |
---|
| 1542 | if isfield(Param.ActionInput,'Fix2') |
---|
| 1543 | Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); |
---|
| 1544 | end |
---|
| 1545 | if isfield(Param.ActionInput,'Patch2') |
---|
| 1546 | Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); |
---|
| 1547 | end |
---|
[860] | 1548 | if isfield(Param,'OutputSubDir') |
---|
| 1549 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
| 1550 | end |
---|
| 1551 | Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B) |
---|
[897] | 1552 | Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); |
---|
| 1553 | Param.IndexRange.last_i=str2num(get(handles.ref_i,'String')); |
---|
| 1554 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
| 1555 | Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); |
---|
| 1556 | Param.IndexRange.last_j=Param.IndexRange.first_j; |
---|
| 1557 | else |
---|
| 1558 | Param.IndexRange.first_j=1; |
---|
| 1559 | Param.IndexRange.last_j=1; |
---|
| 1560 | end |
---|
[860] | 1561 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
[861] | 1562 | if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series |
---|
| 1563 | |
---|
[860] | 1564 | %% create image data ImageData for display |
---|
| 1565 | ImageData.ListVarName={'ny','nx','A'}; |
---|
| 1566 | ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
[1097] | 1567 | ImageData.VarAttribute{1}.Role='coord_y'; |
---|
| 1568 | ImageData.VarAttribute{2}.Role='coord_x'; |
---|
| 1569 | ImageData.VarAttribute{3}.Role='scalar'; |
---|
[860] | 1570 | ImageData.A=imread(Data.Civ1_ImageA); % read the first image |
---|
| 1571 | if ndims(ImageData.A)==3 %case of color image |
---|
| 1572 | ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
| 1573 | end |
---|
| 1574 | ImageData.ny=[size(ImageData.A,1) 1]; |
---|
| 1575 | ImageData.nx=[1 size(ImageData.A,2)]; |
---|
| 1576 | ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly |
---|
[855] | 1577 | |
---|
[860] | 1578 | %% create the figure view_field for image visualization |
---|
| 1579 | hview_field=view_field(ImageData); %view the image in the GUI view_field |
---|
| 1580 | set(0,'CurrentFigure',hview_field) |
---|
| 1581 | hhview_field=guihandles(hview_field); |
---|
| 1582 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
| 1583 | ViewData=get(hview_field,'UserData'); |
---|
| 1584 | ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field |
---|
| 1585 | ViewData.PlotAxes.X=Data.Civ1_X'; |
---|
| 1586 | ViewData.PlotAxes.Y=Data.Civ1_Y'; |
---|
| 1587 | ViewData.PlotAxes.B=imread(Data.Civ1_ImageB);%store the second image in the UserData of the GUI view_field |
---|
| 1588 | set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field |
---|
[855] | 1589 | |
---|
| 1590 | %% look for a current figure for image correlation display |
---|
| 1591 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
[597] | 1592 | if isempty(corrfig) |
---|
| 1593 | corrfig=figure; |
---|
| 1594 | set(corrfig,'tag','corrfig') |
---|
| 1595 | set(corrfig,'name','image correlation') |
---|
| 1596 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
[692] | 1597 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
| 1598 | else |
---|
| 1599 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
| 1600 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
| 1601 | if ~isempty(corrfig) |
---|
| 1602 | delete(corrfig) |
---|
| 1603 | end |
---|
| 1604 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
| 1605 | if ~isempty(hview_field) |
---|
| 1606 | delete(hview_field) |
---|
| 1607 | end |
---|
[597] | 1608 | end |
---|
[774] | 1609 | else |
---|
| 1610 | hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field |
---|
| 1611 | if ~isempty(hview_field) |
---|
| 1612 | delete(hview_field) |
---|
| 1613 | end |
---|
[597] | 1614 | end |
---|
| 1615 | |
---|
[774] | 1616 | % -------------------------------------------------------------------- |
---|
| 1617 | % --- Executes on button press in TestPatch1. |
---|
| 1618 | % -------------------------------------------------------------------- |
---|
| 1619 | function TestPatch1_Callback(hObject, eventdata, handles) |
---|
[1155] | 1620 | msgbox_uvmat('WARNING','open the civ file and run "series/test_filter_tps" ') |
---|
[597] | 1621 | |
---|
[856] | 1622 | |
---|
[1141] | 1623 | %'nomtype2pair': creates nomenclature for index pairs knowing the image nomenclature |
---|
[597] | 1624 | %--------------------------------------------------------------------- |
---|
[1020] | 1625 | function NomTypeNc=nomtype2pair(NomTypeIma,mode_selected) |
---|
[597] | 1626 | %--------------------------------------------------------------------- |
---|
| 1627 | % OUTPUT: |
---|
| 1628 | % NomTypeNc |
---|
| 1629 | %--------------------------------------------------------------------- |
---|
| 1630 | % INPUT: |
---|
| 1631 | % 'NomTypeIma': string defining the kind of nomenclature used for images |
---|
| 1632 | |
---|
| 1633 | NomTypeNc=NomTypeIma;%default |
---|
[1020] | 1634 | switch mode_selected |
---|
[597] | 1635 | case 'pair j1-j2' |
---|
| 1636 | if ~isempty(regexp(NomTypeIma,'a$')) |
---|
| 1637 | NomTypeNc=[NomTypeIma 'b']; |
---|
| 1638 | elseif ~isempty(regexp(NomTypeIma,'A$')) |
---|
| 1639 | NomTypeNc=[NomTypeIma 'B']; |
---|
| 1640 | else |
---|
| 1641 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 1642 | if ~isempty(r) |
---|
| 1643 | NomTypeNc='_1_1-2'; |
---|
| 1644 | end |
---|
| 1645 | end |
---|
| 1646 | case 'series(Dj)' |
---|
| 1647 | % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 1648 | % if ~isempty(r) |
---|
| 1649 | NomTypeNc='_1_1-2'; |
---|
| 1650 | % end |
---|
| 1651 | case 'series(Di)' |
---|
| 1652 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
| 1653 | if ~isempty(r) |
---|
| 1654 | NomTypeNc='_1-2_1'; |
---|
| 1655 | else |
---|
| 1656 | NomTypeNc='_1-2'; |
---|
| 1657 | end |
---|
| 1658 | end |
---|
| 1659 | |
---|
| 1660 | |
---|
[645] | 1661 | %------------------------------------------------------------------------ |
---|
| 1662 | % --- determine the list of index pairs of processing file |
---|
[1020] | 1663 | function [ind1,ind2,mode_selected]=... |
---|
[645] | 1664 | find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j) |
---|
| 1665 | %------------------------------------------------------------------------ |
---|
| 1666 | ind1=''; |
---|
| 1667 | ind2=''; |
---|
| 1668 | r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
| 1669 | if ~isempty(r) |
---|
[1020] | 1670 | mode_selected=['D' r.ind]; |
---|
[645] | 1671 | ind1=stra2num(r.num1); |
---|
| 1672 | ind2=stra2num(r.num2); |
---|
| 1673 | else |
---|
[1020] | 1674 | mode_selected='burst'; |
---|
[645] | 1675 | r=regexp(str_civ,'^j= (?<num1>[a-z])-(?<num2>[a-z])','names'); |
---|
| 1676 | if ~isempty(r) |
---|
| 1677 | NomTypeNc='_1ab'; |
---|
| 1678 | else |
---|
| 1679 | r=regexp(str_civ,'^j= (?<num1>[A-Z])-(?<num2>[A-Z])','names'); |
---|
| 1680 | if ~isempty(r) |
---|
| 1681 | NomTypeNc='_1AB'; |
---|
| 1682 | else |
---|
| 1683 | r=regexp(str_civ,'^j= (?<num1>\d+)-(?<num2>\d+)','names'); |
---|
| 1684 | if ~isempty(r) |
---|
| 1685 | NomTypeNc='_1_1-2'; |
---|
| 1686 | end |
---|
| 1687 | end |
---|
| 1688 | end |
---|
| 1689 | if isempty(r) |
---|
| 1690 | display('wrong pair mode input option') |
---|
| 1691 | else |
---|
| 1692 | ind1=stra2num(r.num1); |
---|
| 1693 | ind2=stra2num(r.num2); |
---|
| 1694 | end |
---|
| 1695 | end |
---|
[774] | 1696 | |
---|
| 1697 | %------------------------------------------------------------------------ |
---|
| 1698 | % --- fill civ_input with the parameters retrieved from an input Civ file |
---|
| 1699 | %------------------------------------------------------------------------ |
---|
| 1700 | function fill_civ_input(Data,handles) |
---|
| 1701 | |
---|
| 1702 | %% Civ param |
---|
| 1703 | % lists of parameters to enter |
---|
| 1704 | ListParamNum={'CorrBoxSize','SearchBoxSize','SearchBoxShift','Dx','Dy','Dz','MinIma','MaxIma'};% list of numerical values (to transform in strings) |
---|
| 1705 | ListParamValue={'CorrSmooth','CheckGrid','CheckMask','CheckThreshold'}; |
---|
| 1706 | ListParamString={'Grid','Mask'}; |
---|
| 1707 | % CorrSmooth ?? |
---|
| 1708 | option={'Civ1','Civ2'}; |
---|
| 1709 | for ichoice=1:2 |
---|
| 1710 | if isfield(Data,[option{ichoice} '_CorrBoxSize']) |
---|
| 1711 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
| 1712 | end |
---|
| 1713 | end |
---|
| 1714 | |
---|
| 1715 | %% Fix param |
---|
| 1716 | option={'Fix1','Fix2'}; |
---|
| 1717 | for ichoice=1:2 |
---|
| 1718 | if isfield(Data,[option{ichoice} '_CheckFmin2']) |
---|
| 1719 | ListParamNum={'MinVel','MaxVel','MinCorr'};% list of numerical values (to transform in strings) |
---|
| 1720 | ListParamValue={'CheckFmin2','CheckF3','CheckF4'}; |
---|
| 1721 | ListParamString={'ref_fix_1'}; |
---|
| 1722 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
| 1723 | end |
---|
| 1724 | end |
---|
| 1725 | |
---|
| 1726 | %% Patch param |
---|
| 1727 | option={'Patch1','Patch2'}; |
---|
| 1728 | for ichoice=1:2 |
---|
| 1729 | if isfield(Data,[option{ichoice} '_FieldSmooth']) |
---|
| 1730 | ListParamNum={'FieldSmooth','MaxDiff','SubDomainSize'};% list of numerical values (to transform in strings) |
---|
| 1731 | ListParamValue={}; |
---|
| 1732 | ListParamString={}; |
---|
| 1733 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
| 1734 | end |
---|
| 1735 | end |
---|
| 1736 | %------------------------------------------------------------------------ |
---|
| 1737 | % --- fill a panel of civ_input with the parameters retrieved from an input Civ file |
---|
| 1738 | %------------------------------------------------------------------------ |
---|
| 1739 | function fill_panel(Data,handles,panel,ListParamNum,ListParamValue,ListParamString) |
---|
| 1740 | children=get(handles.(panel),'children');%handles of the children of the input GUI with handle 'GUI_handle' |
---|
| 1741 | handles_panel=[]; |
---|
| 1742 | for ichild=1:numel(children) |
---|
| 1743 | if ~isempty(get(children(ichild),'tag')) |
---|
| 1744 | handles_panel.(get(children(ichild),'tag'))=children(ichild); |
---|
| 1745 | end |
---|
| 1746 | end |
---|
| 1747 | for ilist=1:numel(ListParamNum) |
---|
| 1748 | ParamName=ListParamNum{ilist}; |
---|
| 1749 | CivParamName=[panel '_' ParamName]; |
---|
| 1750 | if isfield(Data,CivParamName) |
---|
| 1751 | for icoord=1:numel(Data.(CivParamName)) |
---|
| 1752 | if numel(Data.(CivParamName))>1 |
---|
| 1753 | Tag=['num_' ParamName '_' num2str(icoord)]; |
---|
| 1754 | else |
---|
| 1755 | Tag=['num_' ParamName]; |
---|
| 1756 | end |
---|
| 1757 | if isfield(handles_panel,Tag) |
---|
| 1758 | set(handles_panel.(Tag),'String',num2str(Data.(CivParamName)(icoord))) |
---|
| 1759 | set(handles_panel.(Tag),'Visible','on') |
---|
| 1760 | end |
---|
| 1761 | end |
---|
| 1762 | end |
---|
| 1763 | end |
---|
| 1764 | for ilist=1:numel(ListParamValue) |
---|
| 1765 | ParamName=ListParamValue{ilist}; |
---|
| 1766 | CivParamName=[panel '_' ParamName]; |
---|
| 1767 | if strcmp(ParamName,'CorrSmooth') |
---|
| 1768 | ParamName=['num_' ParamName]; |
---|
| 1769 | end |
---|
| 1770 | if isfield(Data,CivParamName) |
---|
| 1771 | if isfield(handles_panel,ParamName) |
---|
| 1772 | set(handles_panel.(ParamName),'Value',Data.(CivParamName)) |
---|
| 1773 | end |
---|
| 1774 | end |
---|
| 1775 | end |
---|
| 1776 | for ilist=1:numel(ListParamString) |
---|
| 1777 | ParamName=ListParamString{ilist}; |
---|
| 1778 | CivParamName=[panel '_' ParamName]; |
---|
| 1779 | if isfield(Data,CivParamName) |
---|
| 1780 | if isfield(handles_panel,ParamName) |
---|
| 1781 | set(handles_panel.(ParamName),'String',Data.(CivParamName)) |
---|
| 1782 | end |
---|
| 1783 | end |
---|
| 1784 | end |
---|
| 1785 | |
---|
| 1786 | %------------------------------------------------------------------------ |
---|
[856] | 1787 | % --- Executes on button press in ImportParam. |
---|
[851] | 1788 | %------------------------------------------------------------------------ |
---|
[856] | 1789 | function ImportParam_Callback(hObject, eventdata, handles) |
---|
[824] | 1790 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 1791 | hhseries=guidata(hseries); |
---|
| 1792 | InputTable=get(hhseries.InputTable,'Data');% read the input file(s) table in the GUI series |
---|
| 1793 | oldfile=InputTable{1,1}; |
---|
| 1794 | if isempty(oldfile) |
---|
| 1795 | % use a file name stored in prefdir |
---|
| 1796 | dir_perso=prefdir; |
---|
| 1797 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1798 | if exist(profil_perso,'file') |
---|
| 1799 | h=load (profil_perso); |
---|
| 1800 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
| 1801 | oldfile=h.RootPath; |
---|
| 1802 | end |
---|
| 1803 | end |
---|
| 1804 | end |
---|
| 1805 | filexml=uigetfile_uvmat('pick a xml parameter file for civ',oldfile,'.xml');% get the xml file containing processing parameters |
---|
| 1806 | %proceed only if a file has been introduced by the browser |
---|
| 1807 | if ~isempty(filexml) |
---|
| 1808 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure |
---|
| 1809 | if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange') |
---|
| 1810 | msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''') |
---|
| 1811 | return |
---|
| 1812 | end |
---|
| 1813 | check_input=0; |
---|
| 1814 | if isfield(Param,'ActionInput') |
---|
| 1815 | if isfield(Param.ActionInput,'Program')&& strcmp(Param.ActionInput.Program,'civ_series') |
---|
| 1816 | fill_GUI(Param.ActionInput,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
[856] | 1817 | set(handles.ConfigSource,'String',filexml) |
---|
[824] | 1818 | check_input=1; |
---|
[856] | 1819 | update_CivOptions(handles,0) |
---|
[824] | 1820 | end |
---|
| 1821 | end |
---|
| 1822 | if ~check_input |
---|
| 1823 | msgbox_uvmat('ERROR','invalid config file (not for civ_series') |
---|
| 1824 | return |
---|
| 1825 | end |
---|
| 1826 | end |
---|
[849] | 1827 | |
---|
[1033] | 1828 | %------------------------------------------------------------------------ |
---|
[855] | 1829 | % --- Executes on selection change in CheckCiv3. |
---|
[1033] | 1830 | %------------------------------------------------------------------------ |
---|
[855] | 1831 | function CheckCiv3_Callback(hObject, eventdata, handles) |
---|
[860] | 1832 | |
---|
[1033] | 1833 | %------------------------------------------------------------------------ |
---|
[1020] | 1834 | % --- Executes on button press in CheckRefFile. |
---|
[1033] | 1835 | %------------------------------------------------------------------------ |
---|
[1020] | 1836 | function CheckRefFile_Callback(hObject, eventdata, handles) |
---|
[860] | 1837 | |
---|
[1033] | 1838 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 1839 | hhseries=guidata(hseries); |
---|
| 1840 | InputTable=get(hhseries.InputTable,'Data'); |
---|
| 1841 | i1=str2num(get(hhseries.num_first_i,'String')); |
---|
| 1842 | j1=str2num(get(hhseries.num_first_j,'String')); |
---|
| 1843 | InputFile=fullfile_uvmat(InputTable{1,1},InputTable{1,2},InputTable{1,3},InputTable{1,5},InputTable{1,4},i1,[],j1); |
---|
| 1844 | % browse for a reference file for displacement |
---|
| 1845 | fileref= uigetfile_uvmat('pick a reference image file:',InputFile); |
---|
| 1846 | if ~isempty(fileref) |
---|
| 1847 | FileInfo=get_file_info(fileref); |
---|
| 1848 | CheckImage=strcmp(FileInfo.FieldType,'image');% =1 for images |
---|
| 1849 | if ~CheckImage |
---|
| 1850 | msgbox_uvmat('ERROR',['invalid file type input for reference image: ' FileInfo.FileType ' not an image']) |
---|
| 1851 | else |
---|
| 1852 | if isfield (FileInfo,'NumberOfFrames')&& FileInfo.NumberOfFrames>1 |
---|
| 1853 | set(handles.num_OriginIndex,'Visible','on') |
---|
| 1854 | set(handles.OriginIndex_title,'Visible','on') |
---|
| 1855 | else |
---|
| 1856 | set(handles.num_OriginIndex,'Visible','off') |
---|
| 1857 | set(handles.OriginIndex_title,'Visible','off') |
---|
[1020] | 1858 | end |
---|
[1033] | 1859 | set(handles.RefFile,'String',fileref) |
---|
| 1860 | set(handles.ConfigSource,'String','NEW') |
---|
| 1861 | set(handles.ConfigSource,'BackgroundColor',[1 0 1]) |
---|
| 1862 | end |
---|
| 1863 | end |
---|
[1020] | 1864 | |
---|
[851] | 1865 | %------------------------------------------------------------------------ |
---|
| 1866 | % --- Executes on key press with selection of a uicontrol |
---|
| 1867 | %------------------------------------------------------------------------ |
---|
| 1868 | function keyboard_callback(hObject,eventdata,handles) |
---|
| 1869 | |
---|
| 1870 | ListExclude={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2','ref_i'}; |
---|
| 1871 | if isempty(find(strcmp(get(gco,'Tag'),ListExclude),1))% if the selected uicontrol is not in the Exclude list |
---|
| 1872 | set(handles.ConfigSource,'String','NEW')% indicate that the configuration is new |
---|
[856] | 1873 | set(handles.OK,'BackgroundColor',[1 0 1])% |
---|
| 1874 | drawnow |
---|
[851] | 1875 | end |
---|
[1148] | 1876 | |
---|
| 1877 | |
---|
| 1878 | function num_CorrBoxSize_3_Callback(hObject, eventdata, handles) |
---|
| 1879 | |
---|
| 1880 | |
---|
| 1881 | function num_SearchBoxSize_3_Callback(hObject, eventdata, handles) |
---|
| 1882 | |
---|
| 1883 | |
---|
| 1884 | function MinIndex_j_Callback(hObject, eventdata, handles) |
---|
| 1885 | |
---|
| 1886 | |
---|
| 1887 | % --- Executes on selection change in field_ref2. |
---|
| 1888 | function field_ref2_Callback(hObject, eventdata, handles) |
---|