Index: trunk/src/plot_field.m
===================================================================
--- trunk/src/plot_field.m	(revision 1143)
+++ trunk/src/plot_field.m	(revision 1144)
@@ -730,14 +730,10 @@
                 end
             end
-            
-%                 if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1))
-%                     test_black=1;
-%                 end
-        
+
             if ~isempty(ivar_FF_vec) %&& ~test_false
                 vec_FF=Data.(Data.ListVarName{ivar_FF_vec}); % flags for false vectors
                 if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1))
                     vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for  dubious vectors
-                    vec_FF(find(vec_F==-2))=-2;%set alseFlag to -2 (edge of the search box)
+                    vec_FF(find(vec_F==-2))=1;%set alseFlag to 1(edge of the search box)
                 end
             end
Index: trunk/src/series.m
===================================================================
--- trunk/src/series.m	(revision 1143)
+++ trunk/src/series.m	(revision 1144)
@@ -645,8 +645,17 @@
     else %scan the input folder
         InputTable{iview,3}=regexprep(InputTable{iview,3},'^/','');%suppress '/' at the beginning of the input name
-        i1=str2num(get(handles.num_first_i,'String'));
-        j1=str2num(get(handles.num_first_j,'String'));
-        InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,[]);
-            [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
+        i1=str2double(get(handles.num_first_i,'String'));
+        j1=str2double(get(handles.num_first_j,'String'));
+        j2=[];%default
+        PairString=get(handles.PairString,'Data');
+        if numel(PairString)>=iview
+            checkpair=strfind(PairString{iview},'j=');
+            if checkpair
+                j1=str2double(PairString{iview}(4));
+                j2=str2double(PairString{iview}(6));
+            end
+        end
+        InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,j2);
+        [RootPath,~,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
                 find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
     end
@@ -1311,9 +1320,4 @@
 function num_last_j_Callback(hObject, eventdata, handles)
 %------------------------------------------------------------------------
-% first_j=str2num(get(handles.num_first_j,'String'));
-% last_j=str2num(get(handles.num_last_j,'String'));
-% ref_j=ceil((first_j+last_j)/2);
-% set(handles.num_ref_j,'String', num2str(ref_j))
-% num_ref_j_Callback(hObject, eventdata, handles)
 SeriesData=get(handles.series,'UserData');
 if ~isfield(SeriesData,'Time')
@@ -1346,5 +1350,5 @@
 %Pairs=get(handles.PairString,'Data');
 for iview=1:size(TimeTable,1)
-    if size(SeriesData.Time,1)<iview
+    if numel(SeriesData.Time)<iview
         break
     end
@@ -2689,10 +2693,13 @@
 
 %% NbSlice visibility
-if isfield(ParamOut,'OutputFileMode')&& strcmp(ParamOut.OutputFileMode,'NbSlice')
-    ParamOut.NbSlice='on';
-end
+% if isfield(ParamOut,'OutputFileMode')&& strcmp(ParamOut.OutputFileMode,'NbSlice')
+%     ParamOut.NbSlice='on';
+% end
 if isfield(ParamOut,'NbSlice') && (strcmp(ParamOut.NbSlice,'on')||isnumeric(ParamOut.NbSlice))
     set(handles.num_NbSlice,'Visible','on')
     set(handles.NbSlice_title,'Visible','on')
+    if isnumeric(ParamOut.NbSlice)
+        set(handles.num_NbSlice,'String',num2str(ParamOut.NbSlice))
+    end
 else
     set(handles.num_NbSlice,'Visible','off')
Index: trunk/src/series/civ2vel_3C.m
===================================================================
--- trunk/src/series/civ2vel_3C.m	(revision 1143)
+++ trunk/src/series/civ2vel_3C.m	(revision 1144)
@@ -58,5 +58,5 @@
     ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
-    ParamOut.VelType='one';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
+    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     ParamOut.FieldTransform = 'off';%use the phys  transform function without choice
@@ -108,5 +108,5 @@
 hdisp=disp_uvmat('WAITING...','checking the file series',checkrun);
 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
-if ~isempty(hdisp),delete(hdisp),end;
+if ~isempty(hdisp),delete(hdisp),end
 %%%%%%%%%%%%
 % The cell array filecell is the list of input file names, while
@@ -124,8 +124,4 @@
 %% define the directory for result file (with path=RootPath{1})
 OutputDir=[Param.OutputSubDir Param.OutputDirExt];% subdirectory for output files
-%
-% if ~isfield(Param,'InputFields')
-%     Param.InputFields.FieldName='';
-% end
 
 %% calibration data and timing: read the ImaDoc files
@@ -175,9 +171,8 @@
     CheckOverwrite=Param.CheckOverwrite;
 end
+
 for index=1:NbField
     
-
-    
-      %% generating the name of the merged field
+    %% generating the name of the merged field
     i1=i1_series{1}(index);
     if ~isempty(i2_series{end})
@@ -198,7 +193,4 @@
     OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},'.nc','_1-2',i1,i2,j1,j2);
     
-    %%
-    
-   
     if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
         disp('program stopped by user')
@@ -206,9 +198,9 @@
     end
     
-     if (~CheckOverwrite && exist(OutputFile,'file'))  
-            disp('existing output file already exists, skip to next field')
-            continue% skip iteration if the mode overwrite is desactivated and the result file already exists
-     end   
-     
+    if (~CheckOverwrite && exist(OutputFile,'file'))
+        disp('existing output file already exists, skip to next field')
+        continue% skip iteration if the mode overwrite is desactivated and the result file already exists
+    end
+    
     %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
     Data=cell(1,NbView);%initiate the set Data
@@ -217,121 +209,110 @@
     %get Xphys,Yphys,Zphys from 1 or 2 stereo folders. Positions are taken
     %at the middle between to time step
-   clear ZItemp
-   ZItemp=zeros(size(XI,1),size(XI,2),2);
-   
-   if index==1
+    clear ZItemp
+    ZItemp=zeros(size(XI,1),size(XI,2),2);
+    CheckZ=0;
+    
+    if index==1
         first_img=i1_series{1,1}(1,1); %id of the first image of the series
-   end
-     
-     idtemp=0;
- for indextemp=index:index+1; 
-     idtemp=idtemp+1;
-    if NbView==3 % if there is only 1 stereo folder, extract directly Xphys,Yphys and Zphys
-      
+    end
+    
+    idtemp=0;
+    for indextemp=index:index+1
+        idtemp=idtemp+1;
+        if NbView==3 % if there is only 1 stereo folder, extract directly Xphys,Yphys and Zphys
+            
+            [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
+            
+            if  exist('Data{3}.Civ3_FF','var') % FF is present, remove wrong vector
+                temp=find(Data{3}.Civ3_FF==0);
+                Zphys=Data{3}.Zphys(temp);
+                Yphys=Data{3}.Yphys(temp);
+                Xphys=Data{3}.Xphys(temp);
+            else
+                Zphys=Data{3}.Zphys;
+                Yphys=Data{3}.Yphys;
+                Xphys=Data{3}.Xphys;
+            end
+            
+        elseif NbView==4 % is there is 2 stereo folders, get global U and V and compute Zphys
+            
+            %test if the seconde camera is the same for both folder
+            for i=3:4
+                indpt(i)=strfind(Param.InputTable{i,2},'.'); % indice of the "." is the folder name 1
+                indline(i)=strfind(Param.InputTable{i,2},'-'); % indice of the "-" is the folder name1
+                camname{i}=Param.InputTable{i,2}(indline(i)+1:indpt(i)-1);% extract the second camera name
+            end
+            
+            if strcmp(camname{3},camname{4})==0
+                disp_uvmat('ERROR','The 2 stereo folders should have the same camera for the second position',checkrun)
+                return
+            end
+            
+            [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
+            
+            if exist('Data{3}.Civ3_FF','var') % if FF is present, remove wrong vector
+                temp=find(Data{3}.Civ3_FF==0);
+                Xmid3=Data{3}.Xmid(temp);
+                Ymid3=Data{3}.Ymid(temp);
+                U3=Data{3}.Uphys(temp);
+                V3=Data{3}.Vphys(temp);
+            else
+                Xmid3=Data{3}.Xmid;
+                Ymid3=Data{3}.Ymid;
+                U3=Data{3}.Uphys;
+                V3=Data{3}.Vphys;
+            end
+            %temporary gridd of merging the 2 stereos datas
+            [xq,yq] = meshgrid(min(Xmid3+(U3)/2):(max(Xmid3+(U3)/2)-min(Xmid3+(U3)/2))/128:max(Xmid3+(U3)/2),min(Ymid3+(V3)/2):(max(Ymid3+(V3)/2)-min(Ymid3+(V3)/2))/128:max(Ymid3+(V3)/2));
+            
+            %1st folder : interpolate the first camera (Dalsa1) points on the second (common) camera
+            %(Dalsa 3)
+            x3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Xmid3-(U3)/2,xq,yq);
+            y3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Ymid3-(V3)/2,xq,yq);
+            
+            [Data{4},tild,errormsg] = nc2struct([Param.InputTable{4,1},'/',Param.InputTable{4,2},'/',Param.InputTable{4,3},'_',int2str(first_img+indextemp-1),'.nc']);
+            if exist('Data{4}.Civ3_FF','var') % if FF is present, remove wrong vector
+                temp=find(Data{4}.Civ3_FF==0);
+                Xmid4=Data{4}.Xmid(temp);
+                Ymid4=Data{4}.Ymid(temp);
+                U4=Data{4}.Uphys(temp);
+                V4=Data{4}.Vphys(temp);
+            else
+                Xmid4=Data{4}.Xmid;
+                Ymid4=Data{4}.Ymid;
+                U4=Data{4}.Uphys;
+                V4=Data{4}.Vphys;
+            end
+            
+            %2nd folder :interpolate the first camera (Dalsa2) points on the second (common) camera
+            %(Dalsa 3)
+            x4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Xmid4-(U4)/2,xq,yq);
+            y4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Ymid4-(V4)/2,xq,yq);
+            
+            xmid=reshape((x4Q+x3Q)/2,length(xq(:,1)).*length(xq(1,:)),1);
+            ymid=reshape((y4Q+y3Q)/2,length(yq(:,1)).*length(yq(1,:)),1);
+            u=reshape(x4Q-x3Q,length(xq(:,1)).*length(xq(1,:)),1);
+            v=reshape(y4Q-y3Q,length(yq(:,1)).*length(yq(1,:)),1);
+            
+            
+            [Zphys,Xphys,Yphys,error]=shift2z(xmid, ymid, u, v,XmlData); %get Xphy,Yphy and Zphys
+            %remove NaN
+            tempNaN=isnan(Zphys);tempind=find(tempNaN==1);
+            Zphys(tempind)=[];
+            Xphys(tempind)=[];
+            Yphys(tempind)=[];       
+        end
         
-        
-        [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']); 
-       
-        if  exist('Data{3}.Civ3_FF','var') % FF is present, remove wrong vector
-            temp=find(Data{3}.Civ3_FF==0);
-            Zphys=Data{3}.Zphys(temp);
-            Yphys=Data{3}.Yphys(temp);
-            Xphys=Data{3}.Xphys(temp);
-        else 
-            Zphys=Data{3}.Zphys;
-            Yphys=Data{3}.Yphys;
-            Xphys=Data{3}.Xphys;
-        end
-        
-        
-        
-    elseif NbView==4 % is there is 2 stereo folders, get global U and V and compute Zphys
-        
-        
-        %test if the seconde camera is the same for both folder
-        for i=3:4
-        indpt(i)=strfind(Param.InputTable{i,2},'.'); % indice of the "." is the folder name 1
-        indline(i)=strfind(Param.InputTable{i,2},'-'); % indice of the "-" is the folder name1
-        camname{i}=Param.InputTable{i,2}(indline(i)+1:indpt(i)-1);% extract the second camera name 
-        end
-        
-        if strcmp(camname{3},camname{4})==0 
-            disp_uvmat('ERROR','The 2 stereo folders should have the same camera for the second position',checkrun)
-            return
-        end
-        
-   
-        
-        [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']); 
-    
-        if exist('Data{3}.Civ3_FF','var') % if FF is present, remove wrong vector
-            temp=find(Data{3}.Civ3_FF==0);
-            Xmid3=Data{3}.Xmid(temp);
-            Ymid3=Data{3}.Ymid(temp);
-            U3=Data{3}.Uphys(temp);
-            V3=Data{3}.Vphys(temp);
-        else 
-            Xmid3=Data{3}.Xmid;
-            Ymid3=Data{3}.Ymid;
-            U3=Data{3}.Uphys;
-            V3=Data{3}.Vphys;
-        end
-        %temporary gridd of merging the 2 stereos datas
-        [xq,yq] = meshgrid(min(Xmid3+(U3)/2):(max(Xmid3+(U3)/2)-min(Xmid3+(U3)/2))/128:max(Xmid3+(U3)/2),min(Ymid3+(V3)/2):(max(Ymid3+(V3)/2)-min(Ymid3+(V3)/2))/128:max(Ymid3+(V3)/2));
-        
-        %1st folder : interpolate the first camera (Dalsa1) points on the second (common) camera
-        %(Dalsa 3)
-        x3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Xmid3-(U3)/2,xq,yq);
-        y3Q=griddata(Xmid3+(U3)/2,Ymid3+(V3)/2,Ymid3-(V3)/2,xq,yq);
-        
-        
-
-         [Data{4},tild,errormsg] = nc2struct([Param.InputTable{4,1},'/',Param.InputTable{4,2},'/',Param.InputTable{4,3},'_',int2str(first_img+indextemp-1),'.nc']); 
-        if exist('Data{4}.Civ3_FF','var') % if FF is present, remove wrong vector
-            temp=find(Data{4}.Civ3_FF==0);
-            Xmid4=Data{4}.Xmid(temp);
-            Ymid4=Data{4}.Ymid(temp);
-            U4=Data{4}.Uphys(temp);
-            V4=Data{4}.Vphys(temp);
-        else 
-            Xmid4=Data{4}.Xmid;
-            Ymid4=Data{4}.Ymid;
-            U4=Data{4}.Uphys;
-            V4=Data{4}.Vphys;
-        end
-        
-        %2nd folder :interpolate the first camera (Dalsa2) points on the second (common) camera
-        %(Dalsa 3)
-        x4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Xmid4-(U4)/2,xq,yq);
-        y4Q=griddata(Xmid4+(U4)/2,Ymid4+(V4)/2,Ymid4-(V4)/2,xq,yq);
-        
-        xmid=reshape((x4Q+x3Q)/2,length(xq(:,1)).*length(xq(1,:)),1);
-        ymid=reshape((y4Q+y3Q)/2,length(yq(:,1)).*length(yq(1,:)),1);
-        u=reshape(x4Q-x3Q,length(xq(:,1)).*length(xq(1,:)),1);
-        v=reshape(y4Q-y3Q,length(yq(:,1)).*length(yq(1,:)),1);
-        
-        
-        [Zphys,Xphys,Yphys,error]=shift2z(xmid, ymid, u, v,XmlData); %get Xphy,Yphy and Zphys
-        %remove NaN 
-        tempNaN=isnan(Zphys);tempind=find(tempNaN==1);
-        Zphys(tempind)=[];
-        Xphys(tempind)=[];
-        Yphys(tempind)=[];
-        error(tempind)=[];
-         
-    end
-    
-            if NbView>2   
-       ZItemp(:,:,idtemp)=griddata(Xphys,Yphys,Zphys,XI,YI); %interpolation on the choosen gridd
-            end
-    
-end
-    ZI=mean(ZItemp,3); %mean between two the two time step
-    Vtest=ZItemp(:,:,2)-ZItemp(:,:,1);
+        if NbView>2
+            ZItemp(:,:,idtemp)=griddata(Xphys,Yphys,Zphys,XI,YI); %interpolation on the choosen gridd
+            CheckZ=1;
+        end      
+    end
+    ZI=mean(ZItemp,3); %mean between the two time step
     
     [Xa,Ya]=px_XYZ(XmlData{1}.GeometryCalib,[],XI,YI,ZI);% set of image coordinates on view a
     [Xb,Yb]=px_XYZ(XmlData{2}.GeometryCalib,[],XI,YI,ZI);% set of image coordinates on view b
     
-   
+    
     for iview=1:2
         %% reading input file(s)
@@ -342,5 +323,5 @@
         end
         % get the time defined in the current file if not already defined from the xml file
-        if isfield(Data{iview},'Time')&& isequal(Data{iview}.Time,Data{1}.Time)
+        if isfield(Data{iview},'Time')&& (Data{iview}.Time-Data{1}.Time)<0.0001
             Time=Data{iview}.Time;
         else
@@ -355,5 +336,5 @@
         end
     end
-    %remove wrong vector  
+    %remove wrong vector
     if isfield(Data{1},'FF')
         temp=find(Data{1}.FF==0);
@@ -373,5 +354,5 @@
     [A]=get_coeff(XmlData{1}.GeometryCalib,Xa,Ya,XI,YI,ZI); %get coef A~
     
-    %remove wrong vector  
+    %remove wrong vector
     if isfield(Data{2},'FF')
         temp=find(Data{2}.FF==0);
@@ -396,5 +377,5 @@
     S=ones(size(XI,1),size(XI,2),3);
     D=ones(size(XI,1),size(XI,2),3,3);
-
+    
     S(:,:,1)=A(:,:,1,1).*Ua+A(:,:,2,1).*Va+B(:,:,1,1).*Ub+B(:,:,2,1).*Vb;
     S(:,:,2)=A(:,:,1,2).*Ua+A(:,:,2,2).*Va+B(:,:,1,2).*Ub+B(:,:,2,2).*Vb;
@@ -416,5 +397,5 @@
             W(indj,indi)=dxyz(3);
         end
-    end   
+    end
     Error=zeros(size(XI,1),size(XI,2),4);
     Error(:,:,1)=A(:,:,1,1).*U+A(:,:,1,2).*V+A(:,:,1,3).*W-Ua;
@@ -424,28 +405,36 @@
     
     
-
-    
-  
-    
     %% recording the merged field
     if index==1% initiate the structure at first index
-        MergeData.ListGlobalAttribute={'Conventions','Time','Dt'};
+        MergeData.ListGlobalAttribute={'Conventions','Time','Dt','CoordUnit'};
         MergeData.Conventions='uvmat';
-        MergeData.Time=Time;
-        MergeData.Dt=Dt;
-        MergeData.ListVarName={'coord_x','coord_y','Z','U','V','W','Error'};
+        if isfield (XmlData{1}.GeometryCalib,'CoordUnit') && isfield (XmlData{2}.GeometryCalib,'CoordUnit') && strcmp(XmlData{1}.GeometryCalib.CoordUnit, XmlData{2}.GeometryCalib.CoordUnit)
+        MergeData.CoordUnit=XmlData{1}.GeometryCalib.CoordUnit;
+        else
+            disp_uvmat('ERROR','inconsistent coord units in the two input velocity series',checkrun)
+            return
+        end
+        MergeData.ListVarName={'coord_x','coord_y','U','V','W','Error'};
         MergeData.VarDimName={'coord_x','coord_y',{'coord_y','coord_x'},{'coord_y','coord_x'}...
-                {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'}};
+            {'coord_y','coord_x'},{'coord_y','coord_x'}};
+        MergeData.VarAttribute{6}.unit='pixel'; %error estimate expressed in pixel
+        if CheckZ
+            MergeData.ListVarName=[MergeData.ListVarName {'Z'}];
+            MergeData.VarDimName=[MergeData.ListVarName {'coord_y','coord_x'}];
+            MergeData.Z=ZI;
+        end
         MergeData.coord_x=xI;
         MergeData.coord_y=yI;
     end
+    MergeData.Time=Time;
+    MergeData.Dt=Dt;
     MergeData.U=U/Dt;
     MergeData.V=V/Dt;
     MergeData.W=W/Dt;
-    MergeData.Z=ZI;
-    
-%     mfx=(XmlData{1}.GeometryCalib.fx_fy(1)+XmlData{2}.GeometryCalib.fx_fy(1))/2;
-%     mfy=(XmlData{1}.GeometryCalib.fx_fy(2)+XmlData{2}.GeometryCalib.fx_fy(2))/2;
-    MergeData.Error=0.5*sqrt(sum(Error.^2,3));
+    
+    
+    mfx=(XmlData{1}.GeometryCalib.fx_fy(1)+XmlData{2}.GeometryCalib.fx_fy(1))/2;
+    mfy=(XmlData{1}.GeometryCalib.fx_fy(2)+XmlData{2}.GeometryCalib.fx_fy(2))/2;
+    MergeData.Error=0.25*(mfx+mfy)*sqrt(sum(Error.^2,3));
     errormsg=struct2nc(OutputFile,MergeData);%save result file
     if isempty(errormsg)
Index: trunk/src/series/civ_series.m
===================================================================
--- trunk/src/series/civ_series.m	(revision 1143)
+++ trunk/src/series/civ_series.m	(revision 1144)
@@ -249,5 +249,4 @@
 Data.Program='civ_series';
 Data.CivStage=0;%default
-check_civx=0;%default
 
 %% get timing from the ImaDoc file or input video
@@ -332,5 +331,4 @@
             if strcmp(Param.ActionInput.ListCompareMode,'PIV')
                 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
-%                 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);
             else % displacement
                 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);
@@ -448,5 +446,5 @@
         end
         % set the list of variables
-        Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_F','Civ1_C'};%  cell array containing the names of the fields to record
+        Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_FF'};%  cell array containing the names of the fields to record
         Data.VarDimName={'nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1'};
         Data.VarAttribute{1}.Role='coord_x';
@@ -454,5 +452,6 @@
         Data.VarAttribute{3}.Role='vector_x';
         Data.VarAttribute{4}.Role='vector_y';
-        Data.VarAttribute{5}.Role='warnflag';
+        Data.VarAttribute{5}.Role='ancillary';
+        Data.VarAttribute{6}.Role='errorflag';
         % case of mask
         if par_civ1.CheckMask&&~isempty(par_civ1.Mask)
@@ -487,5 +486,5 @@
             Data.ListVarName=[Data.ListVarName 'Civ1_Z'];
             Data.Civ1_X=[];Data.Civ1_Y=[];Data.Civ1_Z=[];
-            Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[];Data.Civ1_F=[];
+            Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[];
             for ivol=1:NbSlice
                 % caluclate velocity data (y and v in indices, reverse to y component)
@@ -501,5 +500,5 @@
                 Data.Civ1_V=[Data.Civ1_V reshape(-vtable,[],1)];
                 Data.Civ1_C=[Data.Civ1_C reshape(ctable,[],1)];
-                Data.Civ1_F=[Data.Civ1_C reshape(F,[],1)];
+                Data.Civ1_FF=[Data.Civ1_FF reshape(F,[],1)];
             end
         else %usual PIV
@@ -516,5 +515,5 @@
             Data.Civ1_V=reshape(-vtable,[],1);
             Data.Civ1_C=reshape(ctable,[],1);
-            Data.Civ1_F=reshape(F,[],1);
+            Data.Civ1_FF=reshape(F,[],1);
             time_civ1=toc(tstart_civ1);
         end
@@ -557,9 +556,5 @@
         end
         Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix1_param];
-        Data.ListVarName=[Data.ListVarName {'Civ1_FF'}];
-        Data.VarDimName=[Data.VarDimName {'nb_vec_1'}];
-        nbvar=length(Data.ListVarName);
-        Data.VarAttribute{nbvar}.Role='errorflag';
-        Data.Civ1_FF=int8(detect_false(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V));
+        Data.Civ1_FF=uint8(detect_false(Param.ActionInput.Fix1,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V,Data.Civ1_FF));
         Data.CivStage=2;
     end
@@ -568,10 +563,5 @@
         disp('patch1 started')
          tstart_patch1=tic;
-        if check_civx
-            errormsg='Civ Matlab input needed for patch';
-            disp_uvmat('ERROR',errormsg,checkrun)
-            return
-        end
-        
+       
         % record the processing parameters of Patch1 as global attributes in the result nc file
         list_param=fieldnames(Param.ActionInput.Patch1)';
@@ -612,5 +602,5 @@
         Data.Civ1_U_smooth(ind_good)=Ures;% take the interpolated (smoothed) velocity values for good vectors, keep civ1 data for the other
         Data.Civ1_V_smooth(ind_good)=Vres;
-        Data.Civ1_FF(ind_good)=int8(FFres);
+        Data.Civ1_FF(ind_good)=uint8(FFres);
         time_patch1=toc(tstart_patch1);
         disp('patch1 performed')
@@ -802,5 +792,5 @@
         % define the Civ2 variable (if Civ2 data are not replaced from previous calculation)
         if isempty(find(strcmp('Civ2_X',Data.ListVarName),1))
-            Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];%  cell array containing the names of the fields to record
+            Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_C','Civ2_FF'}];%  cell array containing the names of the fields to record
             Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}];
             Data.VarAttribute{nbvar+1}.Role='coord_x';
@@ -808,5 +798,6 @@
             Data.VarAttribute{nbvar+3}.Role='vector_x';
             Data.VarAttribute{nbvar+4}.Role='vector_y';
-            Data.VarAttribute{nbvar+5}.Role='warnflag';
+            Data.VarAttribute{nbvar+5}.Role='ancillary';
+            Data.VarAttribute{nbvar+6}.Role='errorflag';
         end
         Data.Civ2_X=reshape(xtable,[],1);
@@ -815,5 +806,5 @@
         Data.Civ2_V=reshape(-vtable,[],1);
         Data.Civ2_C=reshape(ctable,[],1);
-        Data.Civ2_F=reshape(F,[],1);
+        Data.Civ2_FF=reshape(F,[],1);
         disp('civ2 performed')
         time_civ2=toc(tstart_civ2);
@@ -847,21 +838,7 @@
             Data.(Fix2_param{ilist})=Param.ActionInput.Fix2.(list_param{ilist});
         end
-        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param];
-        if check_civx
-            if ~isfield(Data,'fix2')
-                Data.ListGlobalAttribute=[Data.ListGlobalAttribute 'fix2'];
-                Data.fix2=1;
-                Data.ListVarName=[Data.ListVarName {'vec2_FixFlag'}];
-                Data.VarDimName=[Data.VarDimName {'nb_vectors2'}];
-            end
-            Data.vec_FixFlag=detect_false(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V);
-        else
-            Data.ListVarName=[Data.ListVarName {'Civ2_FF'}];
-            Data.VarDimName=[Data.VarDimName {'nb_vec_2'}];
-            nbvar=length(Data.ListVarName);
-            Data.VarAttribute{nbvar}.Role='errorflag';
-            Data.Civ2_FF=double(detect_false(Param.ActionInput.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V));
-            Data.CivStage=Data.CivStage+1;
-        end
+        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param];     
+        Data.Civ2_FF=double(detect_false(Param.ActionInput.Fix2,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V,Data.Civ2_FF));
+        Data.CivStage=Data.CivStage+1;
     end
     
@@ -1082,6 +1059,6 @@
             if sizemask > 1/2% eliminate point if more than half of the correlation box is masked
                 F(ivec)=3; %
-                utable(ivec)=0;
-                vtable(ivec)=0;
+                utable(ivec)=NaN;
+                vtable(ivec)=NaN;
             else
                 image1_crop=image1_crop.*~mask1_crop;% put to zero the masked pixels (mask1_crop='true'=1)
@@ -1103,6 +1080,6 @@
             end
             if F(ivec)==3
-                utable(ivec)=0;
-                vtable(ivec)=0;
+                utable(ivec)=NaN;
+                vtable(ivec)=NaN;
             else
                 %mask
@@ -1197,5 +1174,5 @@
     peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2);
 else
-    F=-2; % warning flag for vector truncated by the limited search box
+    F=1; % warning flag for vector truncated by the limited search box
 end
 peakx=x;
@@ -1206,5 +1183,5 @@
     peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2);
 else
-    F=-2; % warning flag for vector truncated by the limited search box
+    F=1; % warning flag for vector truncated by the limited search box
 end
 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
@@ -1215,5 +1192,5 @@
 %------------------------------------------------------------------------
 % vector=[0 0]; %default
-F=-2;
+F=1;
 peaky=y;
 peakx=x;
@@ -1258,5 +1235,5 @@
 [npy,npx]=size(result_conv);
 if x<4 || y<4 || npx-x<4 ||npy-y <4
-    F=-2;
+    F=1;
     vector=[x y];
 else
@@ -1292,13 +1269,13 @@
 
 
-function FF=detect_false(Param,F,C,U,V)
-FF=zeros(size(F));%default
-% FF=-2, for correlation max at edge
-% FF=-1, for too small correlation
-% FF=1, for velocity outside bounds
-% FF=2 for exclusion by difference with the smoothed field
-FF(F==-2)=-2;
+function FF=detect_false(Param,C,U,V,FFIn)
+FF=FFIn;%default, good vectors
+% FF=1, for correlation max at edge, not set in this function
+% FF=2, for too small correlation
+% FF=3, for velocity outside bounds
+% FF=4 for exclusion by difference with the smoothed field, not set in this function
+
 if isfield (Param,'MinCorr')
-     FF(C<Param.MinCorr)=-1;
+     FF(C<Param.MinCorr & FFIn==0)=2;
 end
 if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel))
@@ -1306,35 +1283,11 @@
     if isfield (Param,'MinVel')&&~isempty(Param.MinVel)
         U2Min=Param.MinVel*Param.MinVel;
-        FF(Umod<U2Min)=1;
+        FF(Umod<U2Min & FFIn==0)=3;
     end
     if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)
          U2Max=Param.MaxVel*Param.MaxVel;
-        FF(Umod>U2Max)=1;
-    end
-end
-
-
-%criterium on warn flags
-% FlagName={'CheckFmin2','CheckF2','CheckF3','CheckF4'};
-% FlagVal=[-2 2 3 4];
-% for iflag=1:numel(FlagName)
-%     if isfield(Param,FlagName{iflag}) && Param.(FlagName{iflag})
-%         FF=(FF==1| F==FlagVal(iflag));
-%     end
-% end
-% %criterium on correlation values
-% if isfield (Param,'MinCorr')
-%     FF=FF==1 | C<Param.MinCorr;
-% end
-% if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel))
-%     Umod= U.*U+V.*V;
-%     if isfield (Param,'MinVel')&&~isempty(Param.MinVel)
-%         FF=FF==1 | Umod<(Param.MinVel*Param.MinVel);
-%     end
-%     if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)
-%         FF=FF==1 | Umod>(Param.MaxVel*Param.MaxVel);
-%     end
-% end
-
+        FF(Umod>U2Max & FFIn==0)=3;
+    end
+end
 
 %------------------------------------------------------------------------
Index: trunk/src/series/extract_multitif.m
===================================================================
--- trunk/src/series/extract_multitif.m	(revision 1143)
+++ trunk/src/series/extract_multitif.m	(revision 1144)
@@ -77,5 +77,5 @@
     ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
     ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
-    ParamOut.NbSlice='off'; % impose calculation in a single process (no parallel processing to avoid 'holes'))
+    ParamOut.NbSlice='on'; % 
     ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
@@ -91,6 +91,6 @@
         first_j=[];% note that the function will propose to cover the whole range of indices
     if isfield(Param.IndexRange,'MinIndex_j'); first_j=Param.IndexRange.MinIndex_j; end
-    last_j=[];
-    if isfield(Param.IndexRange,'MaxIndex_j'); last_j=Param.IndexRange.MaxIndex_j; end
+% %     last_j=[];
+% %     if isfield(Param.IndexRange,'MaxIndex_j'); last_j=Param.IndexRange.MaxIndex_j; end
     PairString='';
     if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
@@ -101,9 +101,9 @@
         msgbox_uvmat('WARNING',['the first input file ' FirstFileName ' does not exist'])
     end
-
+    ParamOut.NbSlice=Param.IndexRange.MaxIndex_i;
     %% check the validity of  input file types
     FileInfo=get_file_info(FirstFileName);
     if ~strcmp(FileInfo.FileType,'multimage')
-        msgbox_uvmat('ERROR',['invalid file type input: ' FileInfo.FileType ' not an image'])
+        msgbox_uvmat('ERROR',['invalid file type input: ' FileInfo.FileType ' not a tiff image series'])
         return
     end
Index: trunk/src/transform_field/signal_lowpass_filter.m
===================================================================
--- trunk/src/transform_field/signal_lowpass_filter.m	(revision 1144)
+++ trunk/src/transform_field/signal_lowpass_filter.m	(revision 1144)
@@ -0,0 +1,50 @@
+% 'signal_low_pass_filter': low pass filter of input  signals
+
+% OUTPUT: 
+% DataOut: Matlab structure representing the output (filtered) field
+%
+%INPUT:
+% DataIn: Matlab structure representing the input field
+
+%=======================================================================
+% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
+%   http://www.legi.grenoble-inp.fr
+%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
+%
+%     This file is part of the toolbox UVMAT.
+%
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published
+%     by the Free Software Foundation; either version 2 of the license,
+%     or (at your option) any later version.
+%
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (see LICENSE.txt) for more details.
+%=======================================================================
+
+function DataOut=signal_bandpass_filter(DataIn,Param)
+
+%% request input parameters
+if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
+        [DataOut.TransformInput,errormsg] = set_param_input({'WindowLength'},{11},Param)  
+    return
+end
+DataOut=DataIn; 
+WindowLength=Param.TransformInput.WindowLength;
+HalfLength=floor(WindowLength/2);
+WindowLength=2*HalfLength+1;
+WindowLength=2*ceil(WindowLength/2);%set to the closes upper value
+B=ones(1,WindowLength)/WindowLength;
+for ivar=2:numel(DataIn.ListVarName)
+    VarName=DataIn.ListVarName{ivar};
+    DataOut.(VarName)=filter(B,1,DataIn.(VarName));%teke the sliding average on WindowLength values
+end
+CoordName=DataIn.ListVarName{1};
+FirstX=DataIn.(CoordName)(1);
+DataOut.(CoordName)=circshift(DataIn.(CoordName),HalfLength);% shift the x coordinate to compensate phase shift produced by the filter
+DataOut.(CoordName)(1:HalfLength)=FirstX;
+
+
+
Index: trunk/src/uigetfile_uvmat.m
===================================================================
--- trunk/src/uigetfile_uvmat.m	(revision 1143)
+++ trunk/src/uigetfile_uvmat.m	(revision 1144)
@@ -335,4 +335,8 @@
 %-------------------------------------------------------------------------
 ListStruct=dir_uvmat(DirName);% get structure of the current directory
+if ~isstruct(ListStruct)
+    return
+end
+    
 date_index=find(strcmp('datenum',fieldnames(ListStruct)));% find the index of the date displayin the list of fields
 NumFiles=0; %default
