source: trunk/src/series/stereo_input.m @ 1114

Last change on this file since 1114 was 1107, checked in by g7moreau, 3 years ago

Update Copyright to 2022

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