source: trunk/src/series/civ_input.m @ 1188

Last change on this file since 1188 was 1188, checked in by sommeria, 3 days ago

file relabeling implemented for civ_series

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