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