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