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