source: trunk/src/series/civ_input.m

Last change on this file was 1181, checked in by sommeria, 2 days ago

image rescale included in civ_series input

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