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