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

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