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