Index: /trunk/src/series/civ_input.m
===================================================================
--- /trunk/src/series/civ_input.m	(revision 1019)
+++ /trunk/src/series/civ_input.m	(revision 1020)
@@ -60,8 +60,6 @@
 set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
 set(hObject,'WindowKeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
-%set(hObject,'KeyPressFcn',{@KeyPressFcn,handles})%set keyboard action function
 set(handles.ref_i,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function
 set(handles.ref_j,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function
-%set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
 hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series'
 hhseries=guidata(hseries); %handles of the elements in 'series'
@@ -220,8 +218,5 @@
 if isfield(Param.IndexRange,'TimeUnit')&&~isempty(Param.IndexRange.TimeUnit)
     TimeUnit=Param.IndexRange.TimeUnit;
-end
-% if isfield(SeriesData,'TimeSource')
-%     set(handles.TimeSource,'String',SeriesData.TimeSource)
-% end  
+end 
 if isfield(SeriesData,'GeometryCalib')
     tsai=SeriesData.GeometryCalib;
@@ -317,4 +312,8 @@
 end
 
+       if strcmp(Param.ActionInput.ListCompareMode,'displacement')
+            set(handles.PairIndices,'Visible','off')
+        end
+
 %% set the menu and default choice of civ pairs
 if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs
@@ -668,9 +667,7 @@
 OriginIndex='off';
 PairIndices='off';
-DoubleInputSeries='off';
 switch option
     case 'PIV'
-        PairIndices='on';% needs to define index pairs for PIV
-        
+        PairIndices='on';% needs to define index pairs for PIV       
     case 'PIV volume'
         PairIndices='on';% needs to define index pairs for PIV
@@ -680,18 +677,15 @@
     case 'displacement'
         OriginIndex='on';%define a frame origin for displacement
-%     case 'shift'
-%         if numel(ImageType)==1
-%             fileinput=uigetfile_uvmat('pick a second file series for synchronous shift',InputTable{check_nc+1});
-%             if ~isempty(fileinput)
-%                 series( 'display_file_name',hhseries,fileinput,'append')
-%             end
-%             
-%             
-%         end
 end
 set(handles.num_OriginIndex,'Visible',OriginIndex)
 set(handles.OriginIndex_title,'Visible',OriginIndex)
+set(handles.CheckRefFile,'Visible',OriginIndex)
+set(handles.RefFile,'Visible',OriginIndex)
 set(handles.PairIndices,'Visible',PairIndices)
-ListPairMode_Callback(hObject, eventdata, handles)
+ListPairMode_Callback(hObject,eventdata,handles)
+if strcmp(OriginIndex,'on')
+    set(handles.CheckRefFile,'Value',1)
+    CheckRefFile_Callback(hObject,eventdata,handles)
+end
         
 
@@ -708,5 +702,5 @@
 compare=compare_list{val};
 if strcmp(compare,'displacement')||strcmp(compare,'shift')
-    mode='displacement';
+    mode_selected='displacement';
 else
     mode_list=get(handles.ListPairMode,'String');
@@ -718,5 +712,5 @@
         mode_value=1;
     end
-    mode=mode_list{mode_value};
+    mode_selected=mode_list{mode_value};
 end
 % displ_num=[];%default
@@ -734,5 +728,5 @@
 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
 % are relative to the reference indices ref_i and ref_j respectively.
-if isequal(mode,'pair j1-j2')
+if isequal(mode_selected,'pair j1-j2')
     dt=1;
     displ='';
@@ -764,5 +758,5 @@
     displ_num(4,:)=0;
     enable_j(handles, 'off')
-elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)')
+elseif isequal(mode_selected,'series(Dj)') %| isequal(mode,'st_series(Dj)')
     index=1:200;
     displ_num(1,index)=-floor(index/2);
@@ -770,5 +764,5 @@
     displ_num(3:4,index)=zeros(2,200);
     enable_j(handles, 'on')
-elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)')
+elseif isequal(mode_selected,'series(Di)') %| isequal(mode,'st_series(Di)')
 %     index=1:200;
 %     displ_num(1:2,index)=zeros(2,200);
@@ -781,5 +775,5 @@
         enable_j(handles, 'off')
     end
-elseif isequal(mode,'displacement')%the pairs have the same indices
+elseif isequal(mode_selected,'displacement')%the pairs have the same indices
     displ_num(1,1)=0;
     displ_num(2,1)=0;
@@ -855,7 +849,7 @@
 mode_list=get(handles.ListPairMode,'String');
 mode_value=get(handles.ListPairMode,'Value');
-mode=mode_list{mode_value};
+mode_selected=mode_list{mode_value};
 errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files
-if isequal(mode,'series(Di)') || ...% we do patch2 only
+if isequal(mode_selected,'series(Di)') || ...% we do patch2 only
         (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
     errormsg=find_netcpair_civ( handles,2);
@@ -872,28 +866,5 @@
         
 % %------------------------------------------------------------------------
-% function ref_j_Callback(hObject, eventdata, handles)
-% %------------------------------------------------------------------------
-% mode_list=get(handles.ListPairMode,'String');
-% mode_value=get(handles.ListPairMode,'Value');
-% mode=mode_list{mode_value};
-% errormsg='';
-% if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)')
-%     errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files
-% end
-% if isequal(mode,'series(Dj)') || ...
-%         (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
-%     errormsg=find_netcpair_civ(handles,2);
-% end
-% if ~isempty(errormsg)
-%     msgbox_uvmat('ERROR',errormsg)
-% end
-% 
-% function ref_j_KeyPressFcn(hObject, eventdata, handles)
-% set(handles.ref_j,'BackgroundColor',[1 0 1])
-%------------------------------------------------------------------------
-% determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of
-% the field series set by MinIndex_i, incr, last_i
-% index=1: look for pairs for civ1
-% index=2: look for pairs for civ2
+
 function errormsg=find_netcpair_civ(handles,index)
 %------------------------------------------------------------------------
@@ -907,4 +878,5 @@
 val=get(handles.ListCompareMode,'Value');
 compare=compare_list{val};
+mode_selected='displacement';
 if ~strcmp(compare,'displacement')%||strcmp(compare,'shift')
  
@@ -917,5 +889,5 @@
         return
     end
-    mode=mode_list{mode_value};
+    mode_selected=mode_list{mode_value};
 end
 nom_type_ima=CivInputData.NomTypeIma;
@@ -935,5 +907,5 @@
 ref_i=str2double(get(handles.ref_i,'String'));
 ref_j=[];
-if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
+if isequal(mode_selected,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
     ref_j=0;
 elseif strcmp(get(handles.ref_j,'Visible'),'on')
@@ -955,5 +927,5 @@
 
 %% determine the menu display in .ListPairCiv1
-switch mode
+switch mode_selected
     case 'series(Di)'
         for ipair=1:nbpair
@@ -995,6 +967,4 @@
         end
     case 'pair j1-j2'%case of pairs
-%         MinIndex_j=CivInputData.MinIndex_j;
-%         MaxIndex_j=min(CivInputData.MaxIndex_j,10);%limitate the number of pairs to 10x10
         MinIndex_j=str2num(get(handles.MinIndex_j,'String'));
         MaxIndex_j=str2num(get(handles.MaxIndex_j,'String'));
@@ -1131,42 +1101,4 @@
 end   
 if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax))
-%     list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs
-%     index=get(handles.ListPairCiv1,'Value');
-%     pair_string=list_pair{index};
-%     time=get(handles.TimeSource,'UserData'); %get the set of times
-%     pxcm=get(handles.SearchRange,'UserData');
-%     mode_list=get(handles.ListPairMode,'String');
-%     mode_value=get(handles.ListPairMode,'Value');
-%     mode=mode_list{mode_value};      
-%     if isequal (mode, 'series(Di)' )
-%         ref_i=str2double(get(handles.ref_i,'String'));
-%         num1=ref_i-floor(index/2);%  first image numbers
-%         num2=ref_i+ceil(index/2);
-%         num_a=1;
-%         num_b=1;
-%     elseif isequal (mode, 'series(Dj)')
-%         num1=1;
-%         num2=1;
-%         ref_j=str2double(get(handles.ref_j,'String'));
-%         num_a=ref_j-floor(index/2);%  first image numbers
-%         num_b=ref_j+ceil(index/2);
-%     elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D)     
-%         ref_i=str2double(get(handles.ref_i,'String'));
-%         num1=ref_i;
-%         num2=ref_i;
-%                 r=regexp(pair_string,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
-%         if isempty(r)
-%             r=regexp(pair_string,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
-%         end  
-%         num_a=str2num(r.num1);
-%         num_b=str2num(r.num2);
-%     end
-%     dt=time(num2+1,num_b+1)-time(num1+1,num_a+1);
-%     ibx=str2double(get(handles.num_CorrBoxSize_1,'String'));
-%     iby=str2double(get(handles.num_CorrBoxSize_2,'String'));
-%     umin=dt*pxcm*umin;
-%     umax=dt*pxcm*umax;
-%     vmin=dt*pxcm*vmin;
-%     vmax=dt*pxcm*vmax;
     shiftx=round((umin+umax)/2);
     shifty=round((vmin+vmax)/2);
@@ -1555,9 +1487,5 @@
         ind_A=2;
     end
-%     [nbslice, flag_mask]=get_mask(InputTable{ind_A,1},handles);% look for a mask with appropriate name
-%     if isequal(flag_mask,1)
-%         filemask=[num2str(nbslice) 'mask'];
-%         testmask=1;
-%     else % browse for a mask
+ % browse for a mask
         filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
         [FilePath,FileName,Ext]=fileparts(filemask);    
@@ -1570,6 +1498,5 @@
         if ~isempty(filemask)
             testmask=1;
-         end
-%     end
+        end
 end
 if testmask
@@ -2194,5 +2121,5 @@
 %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature
 %---------------------------------------------------------------------
-function NomTypeNc=nomtype2pair(NomTypeIma,mode)
+function NomTypeNc=nomtype2pair(NomTypeIma,mode_selected)
 %---------------------------------------------------------------------           
 % OUTPUT:
@@ -2203,5 +2130,5 @@
 
 NomTypeNc=NomTypeIma;%default
-switch mode
+switch mode_selected
     case 'pair j1-j2'      
     if ~isempty(regexp(NomTypeIma,'a$'))
@@ -2232,5 +2159,5 @@
 %------------------------------------------------------------------------
 % --- determine the list of index pairs of processing file
-function [ind1,ind2,mode]=...
+function [ind1,ind2,mode_selected]=...
     find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j)
 %------------------------------------------------------------------------
@@ -2239,9 +2166,9 @@
 r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names');
 if ~isempty(r)
-    mode=['D' r.ind];
+    mode_selected=['D' r.ind];
     ind1=stra2num(r.num1);
     ind2=stra2num(r.num2);
 else
-    mode='burst';
+    mode_selected='burst';
     r=regexp(str_civ,'^j= (?<num1>[a-z])-(?<num2>[a-z])','names');
     if ~isempty(r)
@@ -2402,4 +2329,18 @@
 function CheckCiv3_Callback(hObject, eventdata, handles)
 
+% --- Executes on button press in CheckRefFile.
+function CheckRefFile_Callback(hObject, eventdata, handles)
+
+    hseries=findobj(allchild(0),'Tag','series');
+    hhseries=guidata(hseries);
+    InputTable=get(hhseries.InputTable,'Data');
+    InputFile=fullfile(InputTable{1,1},InputTable{1,2},[InputTable{1,3} InputTable{1,5}]);
+ % browse for a reference file for displacement
+    fileref= uigetfile_uvmat('pick a reference image file:',InputFile);
+        if ~isempty(fileref)
+    set(handles.RefFile,'String',fileref)
+    set(handles.ConfigSource,'String','NEW')
+    set(handles.ConfigSource,'BackgroundColor',[1 0 1])
+        end
 
 %------------------------------------------------------------------------
@@ -2414,25 +2355,2 @@
     drawnow
 end
-
-
-
-function num_NbSlice_Callback(hObject, eventdata, handles)
-% hObject    handle to num_NbSlice (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
-% Hints: get(hObject,'String') returns contents of num_NbSlice as text
-%        str2double(get(hObject,'String')) returns contents of num_NbSlice as a double
-
-
-% --- Executes during object creation, after setting all properties.
-function num_NbSlice_CreateFcn(hObject, eventdata, handles)
-% hObject    handle to num_NbSlice (see GCBO)
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    empty - handles not created until after all CreateFcns called
-
-% Hint: edit controls usually have a white background on Windows.
-%       See ISPC and COMPUTER.
-if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
-    set(hObject,'BackgroundColor','white');
-end
Index: /trunk/src/series/civ_series.m
===================================================================
--- /trunk/src/series/civ_series.m	(revision 1019)
+++ /trunk/src/series/civ_series.m	(revision 1020)
@@ -60,7 +60,4 @@
     Data.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     Data.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
-    %     if isfield(Data,'ActionInput') && isfield(Data.ActionInput,'PairIndices')&& strcmp(Data.ActionInput.PairIndices.ListPairMode,'pair j1-j2')
-    %         Data.Desable_j_index='on';% hide the j index in series (set by the pair choice in civ_input)
-    %     end
     Data.NbSlice='off'; %nbre of slices ('off' by default)
     Data.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
@@ -73,5 +70,5 @@
     Data.OutputFileMode='NbInput_i';% one output file expected per value of i index (used for waitbar)
     Data.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)
-    if isequal(Data.ActionInput.PairIndices.ListPairMode,'pair j1-j2')
+    if isfield(Data.ActionInput,'PairIndices') && strcmp(Data.ActionInput.PairIndices.ListPairMode,'pair j1-j2')
         if isfield(Data.ActionInput.PairIndices,'ListPairCiv2')
             str_civ=Data.ActionInput.PairIndices.ListPairCiv2;
@@ -133,7 +130,7 @@
             iview_A=2;% the second line is used for the input images of Civ2
         end
-        if strcmp(Param.ActionInput.ListCompareMode,'shift')
-            iview_B=iview_A+1; % the second image series is on the next line of the input table
-        end
+%         if strcmp(Param.ActionInput.ListCompareMode,'shift')
+%             iview_B=iview_A+1; % the second image series is on the next line of the input table
+%         end
         if iview_A~=0
             RootPath_A=Param.InputTable{iview_A,1};
@@ -180,24 +177,28 @@
             case 'displacement'
                 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1}));
-                i2_series_Civ1=i1_series{1};i2_series_Civ2=i1_series{1};
-                j1_series_Civ1=ones(size(i1_series{1}));% first j index is 1
-                if isempty(j1_series_Civ1)
-                    j2_series_Civ1=ones(size(i1_series{1}));
+                i1_series_Civ2=i1_series_Civ1;
+                i2_series_Civ1=i1_series{1};
+                i2_series_Civ2=i1_series{1};
+                j1_series_Civ1=[];% no j index variation for the ref image
+                j1_series_Civ2=[];
+                if isempty(j1_series{1})
+                    j2_series_Civ1=ones(size(i1_series_Civ1));
                 else
-                    j2_series_Civ1=j1_series_Civ1;
-                end
-                i1_series_Civ2=i1_series_Civ1;
-                j1_series_Civ2=j1_series_Civ1;
+                    j2_series_Civ1=j1_series{1};% if j index exist  
+                end
                 j2_series_Civ2=j2_series_Civ1;
-                NomTypeNc=Param.InputTable{1,4};
+                NomTypeNc='_1';
             case 'PIV volume'
                 % TODO, TODO
         end
-        if isempty(j1_series_Civ1)
+        %determine frame indices for input with movie or other multiframe input file
+        if isempty(j1_series_Civ1)% simple movie with index i
             FrameIndex_A_Civ1=i1_series_Civ1;
             FrameIndex_B_Civ1=i2_series_Civ1;
             j1_series_Civ1=ones(size(i1_series_Civ1));
+            if strcmp(Param.ActionInput.ListCompareMode,'PIV')
             j2_series_Civ1=ones(size(i1_series_Civ1));
-        else
+            end
+        else % movie for each burst or volume (index j)
             FrameIndex_A_Civ1=j1_series_Civ1;
             FrameIndex_B_Civ1=j2_series_Civ1;
@@ -211,5 +212,7 @@
                 FrameIndex_B_Civ2=i2_series_Civ2;
                 j1_series_Civ2=ones(size(i1_series_Civ2));
+                if strcmp(Param.ActionInput.ListCompareMode,'PIV')
                 j2_series_Civ2=ones(size(i1_series_Civ2));
+                end
             else
                 FrameIndex_A_Civ2=j1_series_Civ2;
@@ -227,5 +230,4 @@
             NbField=numel(i1_series_Civ1);
         elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1
-
             NbField=numel(i1_series_Civ2);
         else
@@ -233,6 +235,4 @@
         end
 
-    
-    
     %% Output directory
     OutputDir='';
@@ -257,5 +257,4 @@
         if isfield(XmlData,'Time')
             Time=XmlData.Time;
-            TimeSource='xml';
         end
         if isfield(XmlData,'Camera')
@@ -271,6 +270,4 @@
         end
     end
-   
-
 end
 
@@ -342,8 +339,12 @@
             disp('civ1 started')
         end
-        par_civ1=Param.ActionInput.Civ1;
+        par_civ1=Param.ActionInput.Civ1;% parameters for civ1
         if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B)
             try
+                if strcmp(Param.ActionInput.ListCompareMode,'displacement')
+                    ImageName_A=Param.ActionInput.RefFile;
+                else
                 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));
+                end
                 if strcmp(FileExt_A,'.nc')% case of input images in format netcdf
                     FieldName_A=Param.InputFields.FieldName;
@@ -351,5 +352,5 @@
                     par_civ1.ImageA=DataIn.(FieldName_A);
                 else % usual image formats for image A
-                    if isempty(FileType_A)
+                    if isempty(FileType_A)% open the image object if not already done in case of movie input
                         [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A);
                         FileType_A=FileInfo_A.FileType;
@@ -357,6 +358,4 @@
                             Time=zeros(FileInfo_A.NumberOfFrames+1,2);
                             Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)';
-                            TimeSource='video';
-                            ColorType='truecolor';
                         end
                         if ~isempty(FileType_A) && isempty(Time)% Time = index i +0.001 index j by default
@@ -596,19 +595,9 @@
             par_civ2.ImageA=[];
             par_civ2.ImageB=[];
-            %             i1_civ2=i1_series_Civ2(ifield);
-            %             i2_civ2=i1_civ2;
-            %             if ~isempty(i2_series_Civ2)
-            %                 i2_civ2=i2_series_Civ2(ifield);
-            %             end
-            %             j1_civ2=1;
-            %             if ~isempty(j1_series_Civ2)
-            %                 j1_civ2=j1_series_Civ2(ifield);
-            %             end
-            %             j2_civ2=i1_civ2;
-            %             if ~isempty(j2_series_Civ2)
-            %                 j2_civ2=j2_series_Civ2(ifield);
-            %             end
+            if strcmp(Param.ActionInput.ListCompareMode,'displacement')
+                    ImageName_A_Civ2=Param.ActionInput.RefFile;
+                else
             ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2);
-            
+            end
             if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield))
                 par_civ2.ImageA=par_civ1.ImageA;
@@ -622,9 +611,4 @@
                 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield));
             end
-            %             if strcmp(Param.ActionInput.ListCompareMode,'PIV')
-            %                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2);
-            %             else % displacement
-            %                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2);
-            %             end
             par_civ2.ImageWidth=FileInfo_A.Width;
             par_civ2.ImageHeight=FileInfo_A.Height;
