Index: trunk/src/series/sub_background.m
===================================================================
--- trunk/src/series/sub_background.m	(revision 1031)
+++ trunk/src/series/sub_background.m	(revision 1032)
@@ -107,5 +107,5 @@
 
     %% check the validity of  input file types
-    ImageTypeOptions={'image','multimage','mmreader','video','cine_phantom'};%allowed input file types(images)
+    ImageTypeOptions={'image','multimage','mmreader','video','cine_phantom','image_DaVis'};%allowed input file types(images)
     FileInfo=get_file_info(FirstFileName);
     FileType=FileInfo.FileType;
@@ -348,4 +348,7 @@
             imwrite(C,newname,'BitDepth',16); % save the new image
         else
+            if ~isfield(FileInfo{1},'BitDepth')
+                FileInfo{1}.BitDepth=16;
+            end
             if isequal(FileInfo{1}.BitDepth,16)
                 C=uint16(Acor);
@@ -379,5 +382,5 @@
                 end
                 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1);
-                Aread=read_image(filename,FileType{1},MovieObject{1},i1_series{1}(ifile));
+                Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile));
                 if ndims(Aread)==3;%color images
                     Aread=sum(double(Aread),3);% take the sum of color components
Index: trunk/src/series/turb_stat.m
===================================================================
--- trunk/src/series/turb_stat.m	(revision 1031)
+++ trunk/src/series/turb_stat.m	(revision 1032)
@@ -180,4 +180,8 @@
     InputFields{1}=Param.InputFields;
 end
+if isempty(InputFields{1}.FieldName)
+    disp('ERROR: input fields U, V and posibly curl and div must be entered by get_field...')
+    return
+end
 
 nbfiles=0;
@@ -187,7 +191,7 @@
 DataOut.ListGlobalAttribute= {'Conventions'};
 DataOut.Conventions= 'uvmat';
-DataOut.ListVarName={'coord_y', 'coord_x' ,'UMean' , 'VMean','u2Mean','v2Mean','u2Mean_1','v2Mean_1','uvMean','Counter'};
+DataOut.ListVarName={'coord_y', 'coord_x' ,'UMean' , 'VMean','u2Mean','v2Mean','u2Mean_1','v2Mean_1','uvMean','CurlMean','DivMean','Curl2Mean','Div2Mean','Counter'};
 DataOut.VarDimName={'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'},...
-    {'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'},{'coord_y','coord_x'}};
 DataOut.UMean=0;
 DataOut.VMean=0;
@@ -198,4 +202,8 @@
 DataOut.uvMean=0;
 DataOut.Counter=0;
+DataOut.CurlMean=0;
+DataOut.DivMean=0;
+DataOut.Curl2Mean=0;
+DataOut.Div2Mean=0;
 U2Mean=0;
 V2Mean=0;
@@ -215,14 +223,15 @@
 
     %%%%%%%%%%%% MAIN RUNNING OPERATIONS  %%%%%%%%%%%%
-    if index==1 %first field
+    if index==1 %initiate the output data structure in the first field
         
         DataOut.coord_y=Field.coord_y;
         DataOut.coord_x=Field.coord_x;
-        Uprev=Field.U;
+        Uprev=Field.U;% store the current field for next iteration
         Vprev=Field.V;
         if isfield(Field,'FF')
-        FFprev=Field.FF;
+        FFprev=Field.FF;% possible flag for false data 
         else
-            FFprev=true(size(Field.U));
+            %FFprev=true(size(Field.U));
+            FFprev=isnan(Field.U);
         end
     end
@@ -242,4 +251,12 @@
     Vprev=Field.V;
     FFprev=FF;
+    if isfield(Field,'curl') && isfield(Field,'div')
+        Field.curl(FF)=0;% set to 0 the nan values
+        Field.div(FF)=0;
+        DataOut.CurlMean=DataOut.CurlMean+Field.curl;
+        DataOut.DivMean=DataOut.DivMean+Field.div;
+        DataOut.Curl2Mean=DataOut.Curl2Mean+Field.curl.*Field.curl;
+        DataOut.Div2Mean=DataOut.Div2Mean+Field.div.*Field.div;
+    end
 end
 %%%%%%%%%%%%%%%% end loop on field indices %%%%%%%%%%%%%%%%
@@ -258,5 +275,8 @@
 DataOut.u2Mean_1=U2Mean_1-DataOut.UMean.*DataOut.UMean; % normalize the mean
 DataOut.v2Mean_1=V2Mean_1-DataOut.VMean.*DataOut.VMean; % normalize the mean
-
+DataOut.CurlMean=DataOut.CurlMean./DataOut.Counter;
+DataOut.DivMean=DataOut.DivMean./DataOut.Counter;
+DataOut.Curl2Mean=DataOut.Curl2Mean./DataOut.Counter-DataOut.CurlMean.*DataOut.CurlMean;
+DataOut.Div2Mean=DataOut.Div2Mean./DataOut.Counter-DataOut.DivMean.*DataOut.DivMean;
 
 %% calculate the profiles
