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

Last change on this file since 673 was 668, checked in by sommeria, 11 years ago

a few bugs corrected.
multimask introduced in merge_proj
displ_uvmat transformed into disp_uvmat

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