source: trunk/src/series/stereo_input.m

Last change on this file was 1161, checked in by sommeria, 8 days ago

filter_tps modified to avoid possible bugs in case of few vectors, subpixel interpolation slightly modified in civ

File size: 124.4 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-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
13%   http://www.legi.grenoble-inp.fr
14%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.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
1801%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1802%%%%%%%%%%%%%%   TEST functions
1803%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1804%------------------------------------------------------------------------
1805% --- Executes on button press in TestCiv1: prepare the image correlation function
1806%     activated by mouse motion
1807function TestCiv1_Callback(hObject, eventdata, handles)
1808%------------------------------------------------------------------------
1809drawnow
1810if get(handles.TestCiv1,'Value')
1811    set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 
1812    %Param.Action.RUN=1;
1813   
1814      hseries=findobj(allchild(0),'Tag','series');
1815     Param=read_GUI(hseries);
1816     Param.Action.RUN=1;
1817     Param.ActionInput=read_GUI(handles.civ_input);
1818
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.ActionInput,'Civ3')%remove options that may be selected beyond Patch1
1832         Param.ActionInput=rmfield(Param.ActionInput,'Civ3');
1833     end
1834     if isfield(Param.ActionInput,'Fix3')
1835         Param.ActionInput=rmfield(Param.ActionInput,'Fix3');
1836     end
1837     if isfield(Param.ActionInput,'Patch3')
1838         Param.ActionInput=rmfield(Param.ActionInput,'Patch3');
1839     end
1840%      if isfield(Param,'OutputSubDir')
1841%         Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
1842%      end
1843     Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B)
1844     [Data,errormsg, ~, xmlData]=stereo_civ(Param);% get the civ1+fix1 results
1845     % if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series
1846     
1847 %% create image data ImageData for display
1848     ImageData.ListVarName={'ny','nx','A'};
1849     ImageData.VarDimName= {'ny','nx',{'ny','nx'}};
1850
1851     %%%%%%%%%%%%%%%%% modif fonction test %%%%%%%%%%%
1852     ImageData.VarAttribute{1}.Role='coord_y';
1853     ImageData.VarAttribute{2}.Role='coord_x';
1854     ImageData.VarAttribute{3}.Role='scalar';
1855
1856     A{1}=imread(Data.Civ1_ImageA); % read the first image
1857     A{2}=imread(Data.Civ1_ImageB); % read the first image
1858
1859     phys_img = phys_ima(A,xmlData,1);%transform image A in phys coordinates
1860     ImageData.A = phys_img{1};
1861     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1862
1863     if ndims(ImageData.A)==3 %case of color image
1864         ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
1865     end
1866     ImageData.ny=[size(ImageData.A,1) 1];
1867     ImageData.nx=[1 size(ImageData.A,2)];
1868     ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly
1869
1870     %% create the figure view_field for image visualization
1871     hview_field=view_field(ImageData); %view the image in the GUI view_field
1872     set(0,'CurrentFigure',hview_field)
1873     hhview_field=guihandles(hview_field);
1874     set(hview_field,'CurrentAxes',hhview_field.PlotAxes)
1875     ViewData=get(hview_field,'UserData');
1876     ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field
1877     ViewData.PlotAxes.X=Data.Civ1_X';
1878     ViewData.PlotAxes.Y=Data.Civ1_Y';
1879
1880     %%%%%%%%%%%%%%%%%%%%%%%
1881     ViewData.PlotAxes.B=phys_img{2};%store the second image in the UserData of the GUI view_field
1882     %%%%%%%%%%%%%%%%%%%%%%%
1883
1884     set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field
1885   
1886    %% look for a current figure for image correlation display
1887    corrfig=findobj(allchild(0),'tag','corrfig');
1888    if isempty(corrfig)
1889        corrfig=figure;
1890        set(corrfig,'tag','corrfig')
1891        set(corrfig,'name','image correlation')
1892        set(corrfig,'DeleteFcn',{@closeview_field})%
1893        set(handles.TestCiv1,'BackgroundColor',[1 0 0])
1894    else
1895        set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red
1896        corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
1897        if ~isempty(corrfig)
1898            delete(corrfig)
1899        end
1900        hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
1901        if ~isempty(hview_field)
1902            delete(hview_field)
1903        end
1904    end
1905else
1906    hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field
1907    if ~isempty(hview_field)
1908        delete(hview_field)
1909    end     
1910end
1911
1912% --------------------------------------------------------------------
1913% --- Executes on button press in TestPatch1.
1914% --------------------------------------------------------------------
1915function TestPatch1_Callback(hObject, eventdata, handles)
1916
1917if get(handles.TestPatch1,'Value')% if TestPatch1 is activated
1918     set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
1919     set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
1920     hseries=findobj(allchild(0),'Tag','series');
1921     Param=read_GUI(hseries);
1922     Param.Action.RUN=1;
1923     Param.ActionInput=read_GUI(handles.civ_input);
1924
1925     if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
1926         Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
1927     end
1928     if isfield(Param.ActionInput,'Fix2')
1929         Param.ActionInput=rmfield(Param.ActionInput,'Fix2');
1930     end
1931     if isfield(Param.ActionInput,'Patch2')
1932         Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
1933     end
1934     if isfield(Param.ActionInput,'Civ3')%remove options that may be selected beyond Patch1
1935         Param.ActionInput=rmfield(Param.ActionInput,'Civ3');
1936     end
1937     if isfield(Param.ActionInput,'Fix3')
1938         Param.ActionInput=rmfield(Param.ActionInput,'Fix3');
1939     end
1940     if isfield(Param.ActionInput,'Patch3')
1941         Param.ActionInput=rmfield(Param.ActionInput,'Patch3');
1942     end
1943     % if isfield(Param,'OutputSubDir')
1944     % Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
1945     % end
1946
1947     ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
1948     Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
1949
1950     [Data,errormsg]=stereo_civ(Param);% get the civ1+fix1 results
1951     bckcolor=get(handles.civ_input,'Color');
1952     set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
1953     
1954     %% prepare Param for iterative Patch processing without input file reading
1955     Param.Civ1_X=Data.Civ1_X;
1956     Param.Civ1_Y=Data.Civ1_Y;
1957     Param.Civ1_U=Data.Civ1_U;
1958     Param.Civ1_V=Data.Civ1_V;
1959     Param.Civ1_FF=Data.Civ1_FF;
1960
1961     %%%%% modif fonction test %%%%%%
1962     % Param=rmfield(Param,'InputTable');%desactivate input file reading
1963     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1964
1965    if isfield(Param.ActionInput,'Civ1')
1966        Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
1967    end
1968    if isfield(Param.ActionInput,'Fix1')
1969        Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
1970    end
1971    SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
1972    NbGood=numel(find(Data.Civ1_FF==0));
1973    NbExclude=zeros(1,7);% initialize the set of smoothing parameters
1974    DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
1975    Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
1976    for irho=1:7
1977        Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
1978        [Data,errormsg]= stereo_civ(Param);%apply the processing fct
1979
1980        %%%%%%%%%% modif fonction test %%%%%%%%%%%%%%
1981        % if ~isempty(errormsg)
1982        %     msgbox_uvmat('ERROR',errormsg)
1983        %     return
1984        % end
1985        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1986
1987        ind_good=find(Data.Civ1_FF==0);
1988        Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
1989        Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good);
1990        DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff));
1991        NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
1992    end
1993    figure(1)
1994    hold on
1995    semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r')
1996    grid on
1997    legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)')
1998    xlabel('smoothing parameter')
1999    ylabel('smoothing effect')
2000    set(handles.TestPatch1,'BackgroundColor',[0 1 0])
2001else
2002    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
2003    if ~isempty(corrfig)
2004        delete(corrfig)
2005    end
2006    hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
2007    if ~isempty(hview_field)
2008        delete(hview_field)
2009    end
2010end
2011
2012%------------------------------------------------------------------------
2013% --- Executes on button press in TestCiv2.
2014%------------------------------------------------------------------------
2015function TestCiv2_Callback(hObject, eventdata, handles)
2016drawnow
2017if get(handles.TestCiv2,'Value')
2018    set(handles.TestCiv2,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch
2019      hseries=findobj(allchild(0),'Tag','series');
2020     Param=read_GUI(hseries);
2021     Param.Action.RUN=1;
2022     Param.ActionInput=read_GUI(handles.civ_input);
2023
2024     if isfield(Param.ActionInput,'Patch2')
2025         Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
2026     end
2027     if isfield(Param.ActionInput,'Civ3')%remove options that may be selected beyond Patch1
2028         Param.ActionInput=rmfield(Param.ActionInput,'Civ3');
2029     end
2030     if isfield(Param.ActionInput,'Fix3')
2031         Param.ActionInput=rmfield(Param.ActionInput,'Fix3');
2032     end
2033     if isfield(Param.ActionInput,'Patch3')
2034         Param.ActionInput=rmfield(Param.ActionInput,'Patch3');
2035     end
2036
2037     % if isfield(Param,'OutputSubDir')
2038     % Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
2039     % end
2040
2041     Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B)
2042     set(handles.Civ1,'BackgroundColor',[1 1 0])
2043     set(handles.Fix1,'BackgroundColor',[1 1 0])
2044     set(handles.Patch1,'BackgroundColor',[1 1 0])
2045     [Data,errormsg, ~, xmlData]=stereo_civ(Param);% get the civ1+fix1+patch1+civ2+fix2 results
2046     % if ~isempty(errormsg), return, end
2047     
2048     %% create image data ImageData for display
2049     ImageData.ListVarName={'ny','nx','A'};
2050     ImageData.VarDimName= {'ny','nx',{'ny','nx'}};
2051
2052     %%%%%%%%%%%%%%%%% modif fonction test %%%%%%%%%%%
2053     ImageData.VarAttribute{1}.Role='coord_y';
2054     ImageData.VarAttribute{2}.Role='coord_x';
2055     ImageData.VarAttribute{3}.Role='scalar';
2056
2057     A{1}=imread(Data.Civ2_ImageA); % read the first image
2058     A{2}=imread(Data.Civ2_ImageB); % read the first image
2059
2060     phys_img = phys_ima(A,xmlData,1);%transform image A in phys coordinates
2061     ImageData.A = phys_img{1};
2062     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2063
2064     if ndims(ImageData.A)==3 %case of color image
2065         ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
2066     end
2067     ImageData.ny=[size(ImageData.A,1) 1];
2068     ImageData.nx=[1 size(ImageData.A,2)];
2069     ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly
2070
2071     %% create the figure view_field for image visualization
2072    hview_field=view_field(ImageData); %view the image in the GUI view_field
2073    set(0,'CurrentFigure',hview_field)
2074    % plot the boundaries of the subdomains used for patch
2075    for isub=1:size(Data.Civ1_SubRange,3);
2076        pos_x=Data.Civ1_SubRange(1,1,isub);
2077        pos_y=Data.Civ1_SubRange(2,1,isub);
2078        width=Data.Civ1_SubRange(1,2,isub)-Data.Civ1_SubRange(1,1,isub);
2079        height=Data.Civ1_SubRange(2,2,isub)-Data.Civ1_SubRange(2,1,isub);
2080        rectangle('Position',[pos_x pos_y width height],'EdgeColor',[0 0 1])
2081    end
2082    hhview_field=guihandles(hview_field);%
2083    set(hview_field,'CurrentAxes',hhview_field.PlotAxes)
2084    ViewData=get(hview_field,'UserData'); % get the currently plotted field (the image A)
2085    % store info in the UserData of view-field
2086    ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field
2087
2088    %%%%%%%%%%%% modif fonction test %%%%%%%%%%%%%%%%%%%%%%%%%%
2089    ViewData.PlotAxes.B=phys_img{2};%store the second image in the UserData of the GUI view_field
2090    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2091   
2092    ViewData.PlotAxes.X=Data.Civ2_X';
2093    ViewData.PlotAxes.Y=Data.Civ2_Y';
2094    ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by the preliminary run of civ2
2095    ViewData.PlotAxes.ShiftY=Data.Civ2_V';
2096    ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange;
2097    ViewData.PlotAxes.Civ1_NbCentres=Data.Civ1_NbCentres;
2098    ViewData.PlotAxes.Civ1_Coord_tps=Data.Civ1_Coord_tps;
2099    ViewData.PlotAxes.Civ1_U_tps=Data.Civ1_U_tps;
2100    ViewData.PlotAxes.Civ1_V_tps=Data.Civ1_V_tps;
2101    ViewData.PlotAxes.Civ1_Dt=Data.Civ1_Dt;
2102    ViewData.PlotAxes.Civ2_Dt=Data.Civ2_Dt;
2103    set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field
2104    bckcolor=get(handles.civ_input,'Color');
2105    set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calmculation is finished
2106    set(handles.Fix1,'BackgroundColor',bckcolor)
2107    set(handles.Patch1,'BackgroundColor',bckcolor)
2108    drawnow
2109   
2110    %% look for a current figure for image correlation display
2111    corrfig=findobj(allchild(0),'tag','corrfig');
2112    if isempty(corrfig)
2113        corrfig=figure;
2114        set(corrfig,'tag','corrfig')
2115        set(corrfig,'name','image correlation')
2116        set(corrfig,'DeleteFcn',{@closeview_field})%
2117        set(handles.TestCiv2,'BackgroundColor',[1 0 0])
2118    else
2119        set(handles.TestCiv2,'BackgroundColor',[1 0 0])% paint button to red
2120        corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
2121        if ~isempty(corrfig)
2122            delete(corrfig)
2123        end
2124        hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
2125        if ~isempty(hview_field)
2126            delete(hview_field)
2127        end
2128    end   
2129else
2130    hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field
2131    if ~isempty(hview_field)
2132        delete(hview_field)
2133    end     
2134end
2135
2136
2137% --- Executes on button press in TestPatch2.
2138function TestPatch2_Callback(hObject, eventdata, handles)
2139if get(handles.TestPatch2,'Value')% if TestPatch2 is activated
2140     set(handles.TestPatch2,'BackgroundColor',[1 1 0])%paint TestPatch2 button in yellow to indicate activation
2141     set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is activated
2142     set(handles.Fix1,'BackgroundColor',[1 1 0])% indicate fix1 calculation is activated
2143     set(handles.Patch1,'BackgroundColor',[1 1 0])% indicate Patch1 calculation is activated
2144     set(handles.Civ2,'BackgroundColor',[1 1 0])% indicate civ2 calculation is activated
2145     set(handles.Fix2,'BackgroundColor',[1 1 0])% indicate fix2 calculation is activated
2146     hseries=findobj(allchild(0),'Tag','series');
2147     Param=read_GUI(hseries);
2148     Param.Action.RUN=1;
2149     Param.ActionInput=read_GUI(handles.civ_input);
2150     if isfield(Param,'OutputSubDir')
2151     Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
2152     end
2153     ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters
2154     Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch
2155     [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
2156     bckcolor=get(handles.civ_input,'Color');
2157     set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
2158     set(handles.Fix1,'BackgroundColor',bckcolor)% indicate fix1 calculation is finished
2159     set(handles.Patch1,'BackgroundColor',bckcolor)% indicate Patch1 calculation is finished
2160     set(handles.Civ2,'BackgroundColor',bckcolor)% indicate civ2 calculation is finished
2161     set(handles.Fix2,'BackgroundColor',bckcolor)% indicate fix2 calculation is finished
2162     
2163     %% prepare Param for iterative Patch processing without input file reading
2164     Param.Civ2_X=Data.Civ2_X;
2165     Param.Civ2_Y=Data.Civ2_Y;
2166     Param.Civ2_U=Data.Civ2_U;
2167     Param.Civ2_V=Data.Civ2_V;
2168     Param.Civ2_FF=Data.Civ2_FF;
2169     Param=rmfield(Param,'InputTable');%desactivate input file reading
2170    if isfield(Param.ActionInput,'Civ1')
2171        Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
2172    end
2173    if isfield(Param.ActionInput,'Fix1')
2174        Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
2175    end
2176    if isfield(Param.ActionInput,'Patch1')
2177        Param.ActionInput=rmfield(Param.ActionInput,'Patch1');%desactivate fix1:remove fix1 input param if relevant
2178    end
2179    if isfield(Param.ActionInput,'Civ2')
2180        Param.ActionInput=rmfield(Param.ActionInput,'Civ2');%desactivate civ2: remove civ2 input param if relevant
2181    end
2182    if isfield(Param.ActionInput,'Fix2')
2183        Param.ActionInput=rmfield(Param.ActionInput,'Fix2');%desactivate fix1:remove fix1 input param if relevant
2184    end
2185    SmoothingParam=(ParamPatch2.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
2186    NbGood=numel(find(Data.Civ2_FF==0));
2187    NbExclude=zeros(1,7);% initialize the set of smoothing parameters
2188    DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
2189    Param.ActionInput.Patch2=ParamPatch2;% retrieve Patch2 parameters
2190    for irho=1:7
2191        Param.ActionInput.Patch2.FieldSmooth=SmoothingParam(irho);
2192        [Data,errormsg]= civ_series(Param);%apply the processing fct
2193        if ~isempty(errormsg)
2194            msgbox_uvmat('ERROR',errormsg)
2195            return
2196        end
2197        ind_good=find(Data.Civ2_FF==0);
2198        Civ2_U_Diff=Data.Civ2_U(ind_good)-Data.Civ2_U_smooth(ind_good);
2199        Civ2_V_Diff=Data.Civ2_V(ind_good)-Data.Civ2_V_smooth(ind_good);
2200        DiffVel(irho)=sqrt(mean(Civ2_U_Diff.*Civ2_U_Diff+Civ2_V_Diff.*Civ2_V_Diff));
2201        NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
2202    end
2203    figure(1)
2204    hold on
2205    semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r')
2206    grid on
2207    legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)')
2208    xlabel('smoothing parameter')
2209    ylabel('smoothing effect')
2210    set(handles.TestPatch2,'BackgroundColor',[0 1 0])
2211else
2212    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
2213    if ~isempty(corrfig)
2214        delete(corrfig)
2215    end
2216    hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
2217    if ~isempty(hview_field)
2218        delete(hview_field)
2219    end
2220end
2221   
2222
2223%'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature
2224%---------------------------------------------------------------------
2225function NomTypeNc=nomtype2pair(NomTypeIma,mode)
2226%---------------------------------------------------------------------           
2227% OUTPUT:
2228% NomTypeNc
2229%---------------------------------------------------------------------
2230% INPUT:
2231% 'NomTypeIma': string defining the kind of nomenclature used for images
2232
2233NomTypeNc=NomTypeIma;%default
2234switch mode
2235    case 'pair j1-j2'     
2236    if ~isempty(regexp(NomTypeIma,'a$'))
2237        NomTypeNc=[NomTypeIma 'b'];
2238    elseif ~isempty(regexp(NomTypeIma,'A$'))
2239        NomTypeNc=[NomTypeIma 'B'];
2240    else
2241        r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');
2242        if ~isempty(r)
2243            NomTypeNc='_1_1-2';
2244        end
2245    end
2246    case 'series(Dj)' 
2247%         r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');
2248%         if ~isempty(r)
2249            NomTypeNc='_1_1-2';
2250%         end
2251   case 'series(Di)'
2252        r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');
2253        if ~isempty(r)
2254            NomTypeNc='_1-2_1';
2255        else
2256            NomTypeNc='_1-2';
2257        end
2258end
2259
2260
2261%------------------------------------------------------------------------
2262% --- determine the list of index pairs of processing file
2263function [ind1,ind2,mode]=...
2264    find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j)
2265%------------------------------------------------------------------------
2266ind1='';
2267ind2='';
2268r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names');
2269if ~isempty(r)
2270    mode=['D' r.ind];
2271    ind1=stra2num(r.num1);
2272    ind2=stra2num(r.num2);
2273else
2274    mode='burst';
2275    r=regexp(str_civ,'^j= (?<num1>[a-z])-(?<num2>[a-z])','names');
2276    if ~isempty(r)
2277        NomTypeNc='_1ab';
2278    else
2279        r=regexp(str_civ,'^j= (?<num1>[A-Z])-(?<num2>[A-Z])','names');
2280        if ~isempty(r)
2281            NomTypeNc='_1AB';
2282        else
2283            r=regexp(str_civ,'^j= (?<num1>\d+)-(?<num2>\d+)','names');
2284            if ~isempty(r)
2285                NomTypeNc='_1_1-2';
2286            end           
2287        end
2288    end
2289    if isempty(r)
2290        display('wrong pair mode input option')
2291    else
2292    ind1=stra2num(r.num1);
2293    ind2=stra2num(r.num2);
2294    end
2295end
2296
2297%------------------------------------------------------------------------
2298% --- fill stereo_input with the parameters retrieved from an input Civ file
2299%------------------------------------------------------------------------
2300function fill_civ_input(Data,handles)
2301
2302%% Civ param
2303% lists of parameters to enter
2304ListParamNum={'CorrBoxSize','SearchBoxSize','SearchBoxShift','Dx','Dy','Dz','MinIma','MaxIma'};% list of numerical values (to transform in strings)
2305ListParamValue={'CorrSmooth','CheckGrid','CheckMask','CheckThreshold'};
2306ListParamString={'Grid','Mask'};
2307% CorrSmooth ??
2308option={'Civ1','Civ2'};
2309for ichoice=1:2
2310    if isfield(Data,[option{ichoice} '_CorrBoxSize'])
2311        fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString)
2312    end
2313end
2314
2315%% Fix param
2316option={'Fix1','Fix2'};
2317for ichoice=1:2
2318    if isfield(Data,[option{ichoice} '_CheckFmin2'])
2319        ListParamNum={'MinVel','MaxVel','MinCorr'};% list of numerical values (to transform in strings)
2320        ListParamValue={'CheckFmin2','CheckF3','CheckF4'};
2321        ListParamString={'ref_fix_1'};
2322        fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString)
2323    end
2324end
2325
2326%% Patch param
2327option={'Patch1','Patch2'};
2328for ichoice=1:2
2329    if isfield(Data,[option{ichoice} '_FieldSmooth'])
2330        ListParamNum={'FieldSmooth','MaxDiff','SubDomainSize'};% list of numerical values (to transform in strings)
2331        ListParamValue={};
2332        ListParamString={};
2333        fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString)
2334    end
2335end
2336%------------------------------------------------------------------------
2337% --- fill a panel of stereo_input with the parameters retrieved from an input Civ file
2338%------------------------------------------------------------------------
2339function fill_panel(Data,handles,panel,ListParamNum,ListParamValue,ListParamString)
2340children=get(handles.(panel),'children');%handles of the children of the input GUI with handle 'GUI_handle'
2341handles_panel=[];
2342for ichild=1:numel(children)
2343    if ~isempty(get(children(ichild),'tag'))
2344        handles_panel.(get(children(ichild),'tag'))=children(ichild);
2345    end
2346end
2347for ilist=1:numel(ListParamNum)
2348    ParamName=ListParamNum{ilist};
2349    CivParamName=[panel '_' ParamName];
2350    if isfield(Data,CivParamName)
2351        for icoord=1:numel(Data.(CivParamName))
2352            if numel(Data.(CivParamName))>1
2353                Tag=['num_' ParamName '_' num2str(icoord)];
2354            else
2355                Tag=['num_' ParamName];
2356            end
2357            if isfield(handles_panel,Tag)
2358                set(handles_panel.(Tag),'String',num2str(Data.(CivParamName)(icoord)))
2359                set(handles_panel.(Tag),'Visible','on')
2360            end
2361        end
2362    end
2363end
2364for ilist=1:numel(ListParamValue)
2365    ParamName=ListParamValue{ilist};
2366    CivParamName=[panel '_' ParamName];
2367    if strcmp(ParamName,'CorrSmooth')
2368        ParamName=['num_' ParamName];
2369    end
2370    if isfield(Data,CivParamName)
2371        if isfield(handles_panel,ParamName)
2372            set(handles_panel.(ParamName),'Value',Data.(CivParamName))
2373        end
2374    end
2375end
2376for ilist=1:numel(ListParamString)
2377    ParamName=ListParamString{ilist};
2378    CivParamName=[panel '_' ParamName];
2379    if isfield(Data,CivParamName)
2380        if isfield(handles_panel,ParamName)
2381            set(handles_panel.(ParamName),'String',Data.(CivParamName))
2382        end
2383    end
2384end
2385
2386%------------------------------------------------------------------------
2387% --- Executes on button press in ImportParam.
2388%------------------------------------------------------------------------
2389function ImportParam_Callback(hObject, eventdata, handles)
2390hseries=findobj(allchild(0),'Tag','series');
2391hhseries=guidata(hseries);
2392InputTable=get(hhseries.InputTable,'Data');% read the input file(s) table in the GUI series
2393oldfile=InputTable{1,1};
2394if isempty(oldfile)
2395    % use a file name stored in prefdir
2396    dir_perso=prefdir;
2397    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
2398    if exist(profil_perso,'file')
2399        h=load (profil_perso);
2400        if isfield(h,'RootPath') && ischar(h.RootPath)
2401            oldfile=h.RootPath;
2402        end
2403    end
2404end
2405filexml=uigetfile_uvmat('pick a xml parameter file for civ',oldfile,'.xml');% get the xml file containing processing parameters
2406%proceed only if a file has been introduced by the browser
2407if ~isempty(filexml)
2408    Param=xml2struct(filexml);% read the input xml file as a Matlab structure
2409
2410   % Param.Action.RUN=0; %desactivate the input RUN=1
2411    if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange')
2412        msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''')
2413        return
2414    end
2415    check_input=0;
2416    if isfield(Param,'ActionInput')
2417        if isfield(Param.ActionInput,'Program')&& strcmp(Param.ActionInput.Program,'stereo_civ')
2418            fill_GUI(Param.ActionInput,handles.civ_input)% fill the elements of the GUI series with the input parameters
2419            set(handles.ConfigSource,'String',filexml)
2420            check_input=1;
2421            update_CivOptions(handles,0)             
2422        end
2423    end
2424    if ~check_input
2425        msgbox_uvmat('ERROR','invalid config file (not for civ_series')
2426        return
2427    end
2428end
2429
2430
2431%------------------------------------------------------------------------
2432% --- Executes on key press with selection of a uicontrol
2433%------------------------------------------------------------------------
2434function keyboard_callback(hObject,eventdata,handles)
2435   
2436ListExclude={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2','ref_i'};
2437if isempty(find(strcmp(get(gco,'Tag'),ListExclude),1))% if the selected uicontrol is not in the Exclude list
2438    set(handles.ConfigSource,'String','NEW')% indicate that the configuration is new
2439    set(handles.OK,'BackgroundColor',[1 0 1])%
2440    drawnow
2441end
2442
2443
2444
2445function num_FieldSmooth_Callback(hObject, eventdata, handles)
2446% hObject    handle to num_FieldSmooth (see GCBO)
2447% eventdata  reserved - to be defined in a future version of MATLAB
2448% handles    structure with handles and user data (see GUIDATA)
2449
2450% Hints: get(hObject,'String') returns contents of num_FieldSmooth as text
2451%        str2double(get(hObject,'String')) returns contents of num_FieldSmooth as a double
2452
2453
2454% --- Executes during object creation, after setting all properties.
2455function num_FieldSmooth_CreateFcn(hObject, eventdata, handles)
2456% hObject    handle to num_FieldSmooth (see GCBO)
2457% eventdata  reserved - to be defined in a future version of MATLAB
2458% handles    empty - handles not created until after all CreateFcns called
2459
2460% Hint: edit controls usually have a white background on Windows.
2461%       See ISPC and COMPUTER.
2462if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2463    set(hObject,'BackgroundColor','white');
2464end
2465
2466
2467
2468function num_MaxDiff_Callback(hObject, eventdata, handles)
2469% hObject    handle to num_MaxDiff (see GCBO)
2470% eventdata  reserved - to be defined in a future version of MATLAB
2471% handles    structure with handles and user data (see GUIDATA)
2472
2473% Hints: get(hObject,'String') returns contents of num_MaxDiff as text
2474%        str2double(get(hObject,'String')) returns contents of num_MaxDiff as a double
2475
2476
2477% --- Executes during object creation, after setting all properties.
2478function num_MaxDiff_CreateFcn(hObject, eventdata, handles)
2479% hObject    handle to num_MaxDiff (see GCBO)
2480% eventdata  reserved - to be defined in a future version of MATLAB
2481% handles    empty - handles not created until after all CreateFcns called
2482
2483% Hint: edit controls usually have a white background on Windows.
2484%       See ISPC and COMPUTER.
2485if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2486    set(hObject,'BackgroundColor','white');
2487end
2488
2489
2490
2491function num_SubDomainSize_Callback(hObject, eventdata, handles)
2492% hObject    handle to num_SubDomainSize (see GCBO)
2493% eventdata  reserved - to be defined in a future version of MATLAB
2494% handles    structure with handles and user data (see GUIDATA)
2495
2496% Hints: get(hObject,'String') returns contents of num_SubDomainSize as text
2497%        str2double(get(hObject,'String')) returns contents of num_SubDomainSize as a double
2498
2499
2500% --- Executes during object creation, after setting all properties.
2501function num_SubDomainSize_CreateFcn(hObject, eventdata, handles)
2502% hObject    handle to num_SubDomainSize (see GCBO)
2503% eventdata  reserved - to be defined in a future version of MATLAB
2504% handles    empty - handles not created until after all CreateFcns called
2505
2506% Hint: edit controls usually have a white background on Windows.
2507%       See ISPC and COMPUTER.
2508if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2509    set(hObject,'BackgroundColor','white');
2510end
2511
2512
2513
2514function num_Nx_Callback(hObject, eventdata, handles)
2515% hObject    handle to num_Nx (see GCBO)
2516% eventdata  reserved - to be defined in a future version of MATLAB
2517% handles    structure with handles and user data (see GUIDATA)
2518
2519% Hints: get(hObject,'String') returns contents of num_Nx as text
2520%        str2double(get(hObject,'String')) returns contents of num_Nx as a double
2521
2522
2523% --- Executes during object creation, after setting all properties.
2524function num_Nx_CreateFcn(hObject, eventdata, handles)
2525% hObject    handle to num_Nx (see GCBO)
2526% eventdata  reserved - to be defined in a future version of MATLAB
2527% handles    empty - handles not created until after all CreateFcns called
2528
2529% Hint: edit controls usually have a white background on Windows.
2530%       See ISPC and COMPUTER.
2531if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2532    set(hObject,'BackgroundColor','white');
2533end
2534
2535
2536
2537function num_Ny_Callback(hObject, eventdata, handles)
2538% hObject    handle to num_Ny (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 num_Ny as text
2543%        str2double(get(hObject,'String')) returns contents of num_Ny as a double
2544
2545
2546% --- Executes during object creation, after setting all properties.
2547function num_Ny_CreateFcn(hObject, eventdata, handles)
2548% hObject    handle to num_Ny (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% --- Executes on button press in TestPatch2.
2560function togglebutton8_Callback(hObject, eventdata, handles)
2561% hObject    handle to TestPatch2 (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% Hint: get(hObject,'Value') returns toggle state of TestPatch2
2566
2567
2568% % --- Executes on button press in CheckPatch3.
2569% function CheckPatch3_Callback(hObject, eventdata, handles)
2570% % hObject    handle to CheckPatch3 (see GCBO)
2571% % eventdata  reserved - to be defined in a future version of MATLAB
2572% % handles    structure with handles and user data (see GUIDATA)
2573%
2574% % Hint: get(hObject,'Value') returns toggle state of CheckPatch3
2575
2576
2577% --- Executes on button press in CheckFmin2.
2578function CheckFmin2_Callback(hObject, eventdata, handles)
2579% hObject    handle to CheckFmin2 (see GCBO)
2580% eventdata  reserved - to be defined in a future version of MATLAB
2581% handles    structure with handles and user data (see GUIDATA)
2582
2583% Hint: get(hObject,'Value') returns toggle state of CheckFmin2
2584
2585
2586% --- Executes on button press in CheckF4.
2587function CheckF4_Callback(hObject, eventdata, handles)
2588% hObject    handle to CheckF4 (see GCBO)
2589% eventdata  reserved - to be defined in a future version of MATLAB
2590% handles    structure with handles and user data (see GUIDATA)
2591
2592% Hint: get(hObject,'Value') returns toggle state of CheckF4
2593
2594
2595% --- Executes on button press in CheckF3.
2596function CheckF3_Callback(hObject, eventdata, handles)
2597% hObject    handle to CheckF3 (see GCBO)
2598% eventdata  reserved - to be defined in a future version of MATLAB
2599% handles    structure with handles and user data (see GUIDATA)
2600
2601% Hint: get(hObject,'Value') returns toggle state of CheckF3
2602
2603
2604% --- Executes on button press in get_ref_fix2.
2605function checkbox56_Callback(hObject, eventdata, handles)
2606% hObject    handle to get_ref_fix2 (see GCBO)
2607% eventdata  reserved - to be defined in a future version of MATLAB
2608% handles    structure with handles and user data (see GUIDATA)
2609
2610% Hint: get(hObject,'Value') returns toggle state of get_ref_fix2
2611
2612
2613
2614function edit123_Callback(hObject, eventdata, handles)
2615% hObject    handle to ref_fix2 (see GCBO)
2616% eventdata  reserved - to be defined in a future version of MATLAB
2617% handles    structure with handles and user data (see GUIDATA)
2618
2619% Hints: get(hObject,'String') returns contents of ref_fix2 as text
2620%        str2double(get(hObject,'String')) returns contents of ref_fix2 as a double
2621
2622
2623% --- Executes during object creation, after setting all properties.
2624function ref_fix2_CreateFcn(hObject, eventdata, handles)
2625% hObject    handle to ref_fix2 (see GCBO)
2626% eventdata  reserved - to be defined in a future version of MATLAB
2627% handles    empty - handles not created until after all CreateFcns called
2628
2629% Hint: edit controls usually have a white background on Windows.
2630%       See ISPC and COMPUTER.
2631if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2632    set(hObject,'BackgroundColor','white');
2633end
2634
2635
2636
2637function num_MaxVel_Callback(hObject, eventdata, handles)
2638% hObject    handle to num_MaxVel (see GCBO)
2639% eventdata  reserved - to be defined in a future version of MATLAB
2640% handles    structure with handles and user data (see GUIDATA)
2641
2642% Hints: get(hObject,'String') returns contents of num_MaxVel as text
2643%        str2double(get(hObject,'String')) returns contents of num_MaxVel as a double
2644
2645
2646% --- Executes during object creation, after setting all properties.
2647function num_MaxVel_CreateFcn(hObject, eventdata, handles)
2648% hObject    handle to num_MaxVel (see GCBO)
2649% eventdata  reserved - to be defined in a future version of MATLAB
2650% handles    empty - handles not created until after all CreateFcns called
2651
2652% Hint: edit controls usually have a white background on Windows.
2653%       See ISPC and COMPUTER.
2654if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2655    set(hObject,'BackgroundColor','white');
2656end
2657
2658
2659
2660function num_MinVel_Callback(hObject, eventdata, handles)
2661% hObject    handle to num_MinVel (see GCBO)
2662% eventdata  reserved - to be defined in a future version of MATLAB
2663% handles    structure with handles and user data (see GUIDATA)
2664
2665% Hints: get(hObject,'String') returns contents of num_MinVel as text
2666%        str2double(get(hObject,'String')) returns contents of num_MinVel as a double
2667
2668
2669% --- Executes during object creation, after setting all properties.
2670function num_MinVel_CreateFcn(hObject, eventdata, handles)
2671% hObject    handle to num_MinVel (see GCBO)
2672% eventdata  reserved - to be defined in a future version of MATLAB
2673% handles    empty - handles not created until after all CreateFcns called
2674
2675% Hint: edit controls usually have a white background on Windows.
2676%       See ISPC and COMPUTER.
2677if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2678    set(hObject,'BackgroundColor','white');
2679end
2680
2681
2682
2683function num_MinCorr_Callback(hObject, eventdata, handles)
2684% hObject    handle to num_MinCorr (see GCBO)
2685% eventdata  reserved - to be defined in a future version of MATLAB
2686% handles    structure with handles and user data (see GUIDATA)
2687
2688% Hints: get(hObject,'String') returns contents of num_MinCorr as text
2689%        str2double(get(hObject,'String')) returns contents of num_MinCorr as a double
2690
2691
2692% --- Executes during object creation, after setting all properties.
2693function num_MinCorr_CreateFcn(hObject, eventdata, handles)
2694% hObject    handle to num_MinCorr (see GCBO)
2695% eventdata  reserved - to be defined in a future version of MATLAB
2696% handles    empty - handles not created until after all CreateFcns called
2697
2698% Hint: edit controls usually have a white background on Windows.
2699%       See ISPC and COMPUTER.
2700if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2701    set(hObject,'BackgroundColor','white');
2702end
2703
2704
2705% --- Executes on selection change in field_ref2.
2706function field_ref2_Callback(hObject, eventdata, handles)
2707% hObject    handle to field_ref2 (see GCBO)
2708% eventdata  reserved - to be defined in a future version of MATLAB
2709% handles    structure with handles and user data (see GUIDATA)
2710
2711% Hints: contents = cellstr(get(hObject,'String')) returns field_ref2 contents as cell array
2712%        contents{get(hObject,'Value')} returns selected item from field_ref2
2713
2714
2715% --- Executes during object creation, after setting all properties.
2716function field_ref2_CreateFcn(hObject, eventdata, handles)
2717% hObject    handle to field_ref2 (see GCBO)
2718% eventdata  reserved - to be defined in a future version of MATLAB
2719% handles    empty - handles not created until after all CreateFcns called
2720
2721% Hint: popupmenu controls usually have a white background on Windows.
2722%       See ISPC and COMPUTER.
2723if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2724    set(hObject,'BackgroundColor','white');
2725end
2726
2727%
2728% % --- Executes on button press in CheckFix3.
2729% function CheckFix3_Callback(hObject, eventdata, handles)
2730% % hObject    handle to CheckFix3 (see GCBO)
2731% % eventdata  reserved - to be defined in a future version of MATLAB
2732% % handles    structure with handles and user data (see GUIDATA)
2733%
2734% % Hint: get(hObject,'Value') returns toggle state of CheckFix3
2735%
2736
2737
2738function num_CorrBoxSize_1_Callback(hObject, eventdata, handles)
2739% hObject    handle to num_CorrBoxSize_1 (see GCBO)
2740% eventdata  reserved - to be defined in a future version of MATLAB
2741% handles    structure with handles and user data (see GUIDATA)
2742
2743% Hints: get(hObject,'String') returns contents of num_CorrBoxSize_1 as text
2744%        str2double(get(hObject,'String')) returns contents of num_CorrBoxSize_1 as a double
2745
2746
2747% --- Executes during object creation, after setting all properties.
2748function num_CorrBoxSize_1_CreateFcn(hObject, eventdata, handles)
2749% hObject    handle to num_CorrBoxSize_1 (see GCBO)
2750% eventdata  reserved - to be defined in a future version of MATLAB
2751% handles    empty - handles not created until after all CreateFcns called
2752
2753% Hint: edit controls usually have a white background on Windows.
2754%       See ISPC and COMPUTER.
2755if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2756    set(hObject,'BackgroundColor','white');
2757end
2758
2759
2760
2761function num_CorrBoxSize_2_Callback(hObject, eventdata, handles)
2762% hObject    handle to num_CorrBoxSize_2 (see GCBO)
2763% eventdata  reserved - to be defined in a future version of MATLAB
2764% handles    structure with handles and user data (see GUIDATA)
2765
2766% Hints: get(hObject,'String') returns contents of num_CorrBoxSize_2 as text
2767%        str2double(get(hObject,'String')) returns contents of num_CorrBoxSize_2 as a double
2768
2769
2770% --- Executes during object creation, after setting all properties.
2771function num_CorrBoxSize_2_CreateFcn(hObject, eventdata, handles)
2772% hObject    handle to num_CorrBoxSize_2 (see GCBO)
2773% eventdata  reserved - to be defined in a future version of MATLAB
2774% handles    empty - handles not created until after all CreateFcns called
2775
2776% Hint: edit controls usually have a white background on Windows.
2777%       See ISPC and COMPUTER.
2778if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2779    set(hObject,'BackgroundColor','white');
2780end
2781
2782
2783
2784function edit114_Callback(hObject, eventdata, handles)
2785% hObject    handle to num_CorrSmooth (see GCBO)
2786% eventdata  reserved - to be defined in a future version of MATLAB
2787% handles    structure with handles and user data (see GUIDATA)
2788
2789% Hints: get(hObject,'String') returns contents of num_CorrSmooth as text
2790%        str2double(get(hObject,'String')) returns contents of num_CorrSmooth as a double
2791
2792
2793% --- Executes during object creation, after setting all properties.
2794function num_CorrSmooth_CreateFcn(hObject, eventdata, handles)
2795% hObject    handle to num_CorrSmooth (see GCBO)
2796% eventdata  reserved - to be defined in a future version of MATLAB
2797% handles    empty - handles not created until after all CreateFcns called
2798
2799% Hint: edit controls usually have a white background on Windows.
2800%       See ISPC and COMPUTER.
2801if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2802    set(hObject,'BackgroundColor','white');
2803end
2804
2805
2806% --- Executes on button press in CheckDeformation.
2807function checkbox48_Callback(hObject, eventdata, handles)
2808% hObject    handle to CheckDeformation (see GCBO)
2809% eventdata  reserved - to be defined in a future version of MATLAB
2810% handles    structure with handles and user data (see GUIDATA)
2811
2812% Hint: get(hObject,'Value') returns toggle state of CheckDeformation
2813
2814
2815
2816function num_Dx_Callback(hObject, eventdata, handles)
2817% hObject    handle to num_Dx (see GCBO)
2818% eventdata  reserved - to be defined in a future version of MATLAB
2819% handles    structure with handles and user data (see GUIDATA)
2820
2821% Hints: get(hObject,'String') returns contents of num_Dx as text
2822%        str2double(get(hObject,'String')) returns contents of num_Dx as a double
2823
2824
2825% --- Executes during object creation, after setting all properties.
2826function num_Dx_CreateFcn(hObject, eventdata, handles)
2827% hObject    handle to num_Dx (see GCBO)
2828% eventdata  reserved - to be defined in a future version of MATLAB
2829% handles    empty - handles not created until after all CreateFcns called
2830
2831% Hint: edit controls usually have a white background on Windows.
2832%       See ISPC and COMPUTER.
2833if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2834    set(hObject,'BackgroundColor','white');
2835end
2836
2837
2838
2839function num_Dy_Callback(hObject, eventdata, handles)
2840% hObject    handle to num_Dy (see GCBO)
2841% eventdata  reserved - to be defined in a future version of MATLAB
2842% handles    structure with handles and user data (see GUIDATA)
2843
2844% Hints: get(hObject,'String') returns contents of num_Dy as text
2845%        str2double(get(hObject,'String')) returns contents of num_Dy as a double
2846
2847
2848% --- Executes during object creation, after setting all properties.
2849function num_Dy_CreateFcn(hObject, eventdata, handles)
2850% hObject    handle to num_Dy (see GCBO)
2851% eventdata  reserved - to be defined in a future version of MATLAB
2852% handles    empty - handles not created until after all CreateFcns called
2853
2854% Hint: edit controls usually have a white background on Windows.
2855%       See ISPC and COMPUTER.
2856if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2857    set(hObject,'BackgroundColor','white');
2858end
2859
2860
2861% --- Executes on button press in CheckGrid.
2862function checkbox49_Callback(hObject, eventdata, handles)
2863% hObject    handle to CheckGrid (see GCBO)
2864% eventdata  reserved - to be defined in a future version of MATLAB
2865% handles    structure with handles and user data (see GUIDATA)
2866
2867% Hint: get(hObject,'Value') returns toggle state of CheckGrid
2868
2869
2870
2871function Grid_Callback(hObject, eventdata, handles)
2872% hObject    handle to Grid (see GCBO)
2873% eventdata  reserved - to be defined in a future version of MATLAB
2874% handles    structure with handles and user data (see GUIDATA)
2875
2876% Hints: get(hObject,'String') returns contents of Grid as text
2877%        str2double(get(hObject,'String')) returns contents of Grid as a double
2878
2879
2880% --- Executes during object creation, after setting all properties.
2881function Grid_CreateFcn(hObject, eventdata, handles)
2882% hObject    handle to Grid (see GCBO)
2883% eventdata  reserved - to be defined in a future version of MATLAB
2884% handles    empty - handles not created until after all CreateFcns called
2885
2886% Hint: edit controls usually have a white background on Windows.
2887%       See ISPC and COMPUTER.
2888if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2889    set(hObject,'BackgroundColor','white');
2890end
2891
2892
2893% --- Executes on button press in CheckMask.
2894function checkbox50_Callback(hObject, eventdata, handles)
2895% hObject    handle to CheckMask (see GCBO)
2896% eventdata  reserved - to be defined in a future version of MATLAB
2897% handles    structure with handles and user data (see GUIDATA)
2898
2899% Hint: get(hObject,'Value') returns toggle state of CheckMask
2900
2901
2902
2903function Mask_Callback(hObject, eventdata, handles)
2904% hObject    handle to Mask (see GCBO)
2905% eventdata  reserved - to be defined in a future version of MATLAB
2906% handles    structure with handles and user data (see GUIDATA)
2907
2908% Hints: get(hObject,'String') returns contents of Mask as text
2909%        str2double(get(hObject,'String')) returns contents of Mask as a double
2910
2911
2912% --- Executes during object creation, after setting all properties.
2913function Mask_CreateFcn(hObject, eventdata, handles)
2914% hObject    handle to Mask (see GCBO)
2915% eventdata  reserved - to be defined in a future version of MATLAB
2916% handles    empty - handles not created until after all CreateFcns called
2917
2918% Hint: edit controls usually have a white background on Windows.
2919%       See ISPC and COMPUTER.
2920if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2921    set(hObject,'BackgroundColor','white');
2922end
2923
2924
2925% --- Executes on button press in CheckThreshold.
2926function checkbox51_Callback(hObject, eventdata, handles)
2927% hObject    handle to CheckThreshold (see GCBO)
2928% eventdata  reserved - to be defined in a future version of MATLAB
2929% handles    structure with handles and user data (see GUIDATA)
2930
2931% Hint: get(hObject,'Value') returns toggle state of CheckThreshold
2932
2933
2934
2935function num_MinIma_Callback(hObject, eventdata, handles)
2936% hObject    handle to num_MinIma (see GCBO)
2937% eventdata  reserved - to be defined in a future version of MATLAB
2938% handles    structure with handles and user data (see GUIDATA)
2939
2940% Hints: get(hObject,'String') returns contents of num_MinIma as text
2941%        str2double(get(hObject,'String')) returns contents of num_MinIma as a double
2942
2943
2944% --- Executes during object creation, after setting all properties.
2945function num_MinIma_CreateFcn(hObject, eventdata, handles)
2946% hObject    handle to num_MinIma (see GCBO)
2947% eventdata  reserved - to be defined in a future version of MATLAB
2948% handles    empty - handles not created until after all CreateFcns called
2949
2950% Hint: edit controls usually have a white background on Windows.
2951%       See ISPC and COMPUTER.
2952if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2953    set(hObject,'BackgroundColor','white');
2954end
2955
2956
2957
2958function num_MaxIma_Callback(hObject, eventdata, handles)
2959% hObject    handle to num_MaxIma (see GCBO)
2960% eventdata  reserved - to be defined in a future version of MATLAB
2961% handles    structure with handles and user data (see GUIDATA)
2962
2963% Hints: get(hObject,'String') returns contents of num_MaxIma as text
2964%        str2double(get(hObject,'String')) returns contents of num_MaxIma as a double
2965
2966
2967% --- Executes during object creation, after setting all properties.
2968function num_MaxIma_CreateFcn(hObject, eventdata, handles)
2969% hObject    handle to num_MaxIma (see GCBO)
2970% eventdata  reserved - to be defined in a future version of MATLAB
2971% handles    empty - handles not created until after all CreateFcns called
2972
2973% Hint: edit controls usually have a white background on Windows.
2974%       See ISPC and COMPUTER.
2975if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
2976    set(hObject,'BackgroundColor','white');
2977end
2978
2979
2980% --- Executes on button press in TestCiv3.
2981function TestCiv3_Callback(hObject, eventdata, handles)
2982% hObject    handle to TestCiv3 (see GCBO)
2983% eventdata  reserved - to be defined in a future version of MATLAB
2984% handles    structure with handles and user data (see GUIDATA)
2985
2986% Hint: get(hObject,'Value') returns toggle state of TestCiv3
2987
2988
2989
2990function num_SearchBoxSize_1_Callback(hObject, eventdata, handles)
2991% hObject    handle to num_SearchBoxSize_1 (see GCBO)
2992% eventdata  reserved - to be defined in a future version of MATLAB
2993% handles    structure with handles and user data (see GUIDATA)
2994
2995% Hints: get(hObject,'String') returns contents of num_SearchBoxSize_1 as text
2996%        str2double(get(hObject,'String')) returns contents of num_SearchBoxSize_1 as a double
2997
2998
2999% --- Executes during object creation, after setting all properties.
3000function num_SearchBoxSize_1_CreateFcn(hObject, eventdata, handles)
3001% hObject    handle to num_SearchBoxSize_1 (see GCBO)
3002% eventdata  reserved - to be defined in a future version of MATLAB
3003% handles    empty - handles not created until after all CreateFcns called
3004
3005% Hint: edit controls usually have a white background on Windows.
3006%       See ISPC and COMPUTER.
3007if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3008    set(hObject,'BackgroundColor','white');
3009end
3010
3011
3012
3013function num_SearchBoxSize_2_Callback(hObject, eventdata, handles)
3014% hObject    handle to num_SearchBoxSize_2 (see GCBO)
3015% eventdata  reserved - to be defined in a future version of MATLAB
3016% handles    structure with handles and user data (see GUIDATA)
3017
3018% Hints: get(hObject,'String') returns contents of num_SearchBoxSize_2 as text
3019%        str2double(get(hObject,'String')) returns contents of num_SearchBoxSize_2 as a double
3020
3021
3022% --- Executes during object creation, after setting all properties.
3023function num_SearchBoxSize_2_CreateFcn(hObject, eventdata, handles)
3024% hObject    handle to num_SearchBoxSize_2 (see GCBO)
3025% eventdata  reserved - to be defined in a future version of MATLAB
3026% handles    empty - handles not created until after all CreateFcns called
3027
3028% Hint: edit controls usually have a white background on Windows.
3029%       See ISPC and COMPUTER.
3030if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3031    set(hObject,'BackgroundColor','white');
3032end
3033
3034
3035% --- Executes during object deletion, before destroying properties.
3036function num_MinCorr_DeleteFcn(hObject, eventdata, handles)
3037% hObject    handle to num_MinCorr (see GCBO)
3038% eventdata  reserved - to be defined in a future version of MATLAB
3039% handles    structure with handles and user data (see GUIDATA)
3040
3041
3042% --- Executes on button press in CheckLSM.
3043function CheckLSM_Callback(hObject, eventdata, handles)
3044% hObject    handle to CheckLSM (see GCBO)
3045% eventdata  reserved - to be defined in a future version of MATLAB
3046% handles    structure with handles and user data (see GUIDATA)
3047% if get(hObject,'Value')==1
3048%  set(handles.Patch3,'Visible','on')
3049% else
3050%      set(handles.Patch3,'Visible','off')
3051
3052% Hint: get(hObject,'Value') returns toggle state of CheckLSM
3053
3054
3055
3056function num_resolution_Callback(hObject, eventdata, handles)
3057% hObject    handle to num_resolution (see GCBO)
3058% eventdata  reserved - to be defined in a future version of MATLAB
3059% handles    structure with handles and user data (see GUIDATA)
3060
3061% Hints: get(hObject,'String') returns contents of num_resolution as text
3062%        str2double(get(hObject,'String')) returns contents of num_resolution as a double
3063
3064
3065% --- Executes during object creation, after setting all properties.
3066function num_resolution_CreateFcn(hObject, eventdata, handles)
3067% hObject    handle to num_resolution (see GCBO)
3068% eventdata  reserved - to be defined in a future version of MATLAB
3069% handles    empty - handles not created until after all CreateFcns called
3070
3071% Hint: edit controls usually have a white background on Windows.
3072%       See ISPC and COMPUTER.
3073if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3074    set(hObject,'BackgroundColor','white');
3075end
Note: See TracBrowser for help on using the repository browser.