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