Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 434)
+++ /trunk/src/civ.m	(revision 435)
@@ -1,2 +1,3 @@
+
 %'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch)
 %------------------------------------------------------------------------
@@ -63,6 +64,6 @@
         t=xmltree(xmlfile);
         sparam=convert(t);
-    catch
-        errormsg={' Unable to read the file PARAM.xml defining the civx binaries:'; lasterr};
+    catch ME
+        errormsg={' Unable to read the file PARAM.xml defining the civx binaries:';ME.message};
     end
 else
@@ -409,5 +410,5 @@
 % end
 switch FileType
-    case {'image','multimage','video'}
+    case {'image','multimage','video','mmreader'}
     otherwise
         errormsg='invalid input file: enter an image, a movie or civ .nc file';
@@ -1059,5 +1060,5 @@
 
 
-%------------------------------------------------------------------------
+%--------------orm----------------------------------------------------------
 % --- Main lauch command, called by RUN and BATCH
 function errormsg=launch_jobs(hObject, eventdata, handles, batch)
@@ -1227,10 +1228,10 @@
 if ~strcmp(CivMode,'CivX')
     if Param.CheckCiv1
-    [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
-    [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
+        [Param.Civ1.FileTypeA,FileInfo,Param.Civ1.ImageA]=get_file_type(filecell.ima1.civ1{1});
+        [Param.Civ1.FileTypeB,FileInfo,Param.Civ1.ImageB]=get_file_type(filecell.ima2.civ1{1});
     end
     if Param.CheckCiv2
-    [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});
-    [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});
+        [Param.Civ2.FileTypeA,FileInfo,Param.Civ2.ImageA]=get_file_type(filecell.ima1.civ2{1});
+        [Param.Civ2.FileTypeB,FileInfo,Param.Civ2.ImageB]=get_file_type(filecell.ima2.civ2{1});
     end
 end
@@ -1271,6 +1272,5 @@
         if Param.CheckCiv1
             % read image-dependent parameters
-            Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
-            Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
+            
             if ~checkframe% && size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j)
                 Param.Civ1.Dt=(time(i2_civ1(ifile)+1,j2_civ1(j)+1)-time(i1_civ1(ifile)+1,j1_civ1(j)+1));
@@ -1280,20 +1280,30 @@
             Param.Civ1.Time=((time(i2_civ1(ifile)+1,j2_civ1(j)+1)+time(i1_civ1(ifile)+1,j1_civ1(j)+1))/2);
             if strcmp(CivMode,'CivX')
-            Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
-            Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%
-            end
-            form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
-            if isempty(form)
-                ImageInfo=get(VideoReader(filecell.ima1.civ1{1,1}));
+                Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
+                Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%
+            end
+            if strcmp(Param.Civ1.FileTypeA,'video')|| strcmp(Param.Civ1.FileTypeA,'mmreader')
+                %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
+                ImageInfo=get(Param.Civ1.ImageA);
+                %                 elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
+                %                     ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
                 Param.Civ1.ImageBitDepth=ImageInfo.BitsPerPixel/3;
+                if batch
+                    Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};%file name must be used for batch instead of video object
+                    Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
+                end
             else
+                Param.Civ1.ImageA=filecell.ima1.civ1{ifile,j};
+                Param.Civ1.ImageB=filecell.ima2.civ1{ifile,j};
+                form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
                 ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size
                 Param.Civ1.ImageBitDepth=ImageInfo.BitDepth;
             end
+            
             Param.Civ1.ImageWidth=ImageInfo.Width;
             Param.Civ1.ImageHeight=ImageInfo.Height;
-            Param.Civ1.i1=i1_civ1(ifile);
-            Param.Civ1.i2=i2_civ1(ifile);
-            % read mask parameters
+            Param.Civ1.FrameIndexA=i1_civ1(ifile);
+            Param.Civ1.FrameIndexB=i2_civ1(ifile);
+            % read mask )parameters
             if Param.Civ1.CheckMask % the lines below should be changed with the new gui
                 if ~exist(Param.Civ1.Mask,'file')
@@ -1312,5 +1322,5 @@
                         i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1;
                         Param.Civ1.Grid=[filecell.filebase '_' fullfile_uvmat('','',Param.Civ1.Grid,'.grid','_1',i1_grid)];
-%                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
+                        %                         Param.Civ1.Grid=[filecell.filebase '_' name_generator(Param.Civ1.Grid,i1_grid,1,'.grid','_i')];
                         if ~exist(Param.Civ1.GridName,'file')
                             errormsg='grid file absent for civ1';
@@ -1424,6 +1434,22 @@
         end
         if Param.CheckCiv2==1
-            Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
-            Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
+            if strcmp(Param.Civ2.FileTypeA,'video')|| strcmp(Param.Civ2.FileTypeA,'mmreader')
+                %   ImageInfo=get(VideoReader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
+                ImageInfo=get(Param.Civ2.ImageA);
+                %                 elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
+                %                     ImageInfo=get(mmreader(fullfile(Param.RootPath,[Param.RootFile Param.ImaExt])));
+                Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3;
+                if batch
+                    Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};%file name must be used for batch instead of video object
+                    Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
+                end
+            else
+                Param.Civ2.ImageA=filecell.ima1.civ2{ifile,j};
+                Param.Civ2.ImageB=filecell.ima2.civ2{ifile,j};
+                form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
+                ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size
+                Param.Civ2.ImageBitDepth=ImageInfo.BitDepth;
+            end
+            
             if ~checkframe %&& size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
                 Param.Civ2.Dt=time(i2_civ2(ifile)+1,j2_civ2(j)+1)-time(i1_civ2(ifile)+1,j1_civ2(j)+1);
@@ -1463,5 +1489,5 @@
             form=imformats(regexprep(get(handles.ImaExt,'String'),'^.',''));%look for image formats
             if isempty(form)
-                ImageInfo=get(VideoReader(filecell.ima1.civ2{1,1}));
+               % ImageInfo=get(VideoReader(fullfile());
                 Param.Civ2.ImageBitDepth=ImageInfo.BitsPerPixel/3;
             else
@@ -1471,6 +1497,8 @@
             Param.Civ2.ImageWidth=ImageInfo.Width;
             Param.Civ2.ImageHeight=ImageInfo.Height;
-            Param.Civ2.i1=i1_civ2(ifile);
-            Param.Civ2.i2=i2_civ2(ifile);
+            Param.Civ2.FrameIndexA=i1_civ2(ifile);
+             Param.Civ2.FrameIndexB=i2_civ2(ifile);
+%             Param.Civ2.i1=i1_civ2(ifile);
+%             Param.Civ2.i2=i2_civ2(ifile);
             switch CivMode
                 case 'CivX'
@@ -4000,6 +4028,6 @@
     par_civ1.ImageHeight=size(Data.A,1);
     par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
-    par_civ1.i1=i1;
-    par_civ1.i2=i2;
+    par_civ1.FrameIndexA=num2str(i1);
+    par_civ1.FrameIndexB=num2str(i2);
     Param.Civ1=par_civ1;
     Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV 
Index: /trunk/src/civ_matlab.m
===================================================================
--- /trunk/src/civ_matlab.m	(revision 434)
+++ /trunk/src/civ_matlab.m	(revision 435)
@@ -52,11 +52,36 @@
 check_patch1=0;%default
 
+% case of input Param set by an xml file (batch mode)
 if ischar(Param)
     Param=xml2struct(Param); %if Param is the name of an xml file, read this file as a Matlab structure
+    if isfield(Param,'Civ1')
+        if strcmp(Param.Civ1.FileTypeA,'video')
+            Param.Civ1.ImageA=VideoReader(Param.Civ1.ImageA);
+        elseif strcmp(Param.Civ1.FileTypeA,'mmreader')
+            Param.Civ1.ImageA=mmreader(Param.Civ1.ImageA);
+        end
+        if strcmp(Param.Civ1.FileTypeB,'video')
+            Param.Civ1.ImageB=VideoReader(Param.Civ1.ImageB);
+        elseif strcmp(Param.Civ1.FileTypeB,'mmreader')
+            Param.Civ1.ImageB=mmreader(Param.Civ1.ImageB);
+        end
+    end
+    if isfield(Param,'Civ2')
+        if strcmp(Param.Civ2.FileTypeA,'video')
+            Param.Civ2.ImageA=VideoReader(Param.Civ2.ImageA);
+        elseif strcmp(Param.Civ2.FileTypeA,'mmreader')
+            Param.Civ2.ImageA=mmreader(Param.Civ2.ImageA);
+        end
+         if strcmp(Param.Civ2.FileTypeB,'video')
+            Param.Civ2.ImageB=VideoReader(Param.Civ2.ImageB);
+        elseif strcmp(Param.Civ2.FileTypeB,'mmreader')
+            Param.Civ2.ImageB=mmreader(Param.Civ2.ImageB);
+        end
+    end
 end
 
 %% Civ1
 if isfield (Param,'Civ1')
-%     check_civ1=1;% test for further use of civ1 results
+    %     check_civ1=1;% test for further use of civ1 results
     % %% prepare images
     par_civ1=Param.Civ1;
@@ -72,11 +97,20 @@
         end
     else
-        if isfield(par_civ1,'ImageA')&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated
-            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.i1);
-            par_civ1.ImageA=Field.A;%imread(par_civ1.ImageA);%[Field,ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num)
-        end
-        if isfield(par_civ1,'ImageB')&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader'))
-            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.i2);
-            par_civ1.ImageB=Field.A;%=imread(par_civ1.ImageB);
+        if isfield(par_civ1,'ImageA')%&&(ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')) % case with no image: only the PIV grid is calculated
+            
+            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.FrameIndexA);
+            if ~isempty(errormsg)
+                errormsg=['error in civ_matlab/read_field:' errormsg];
+                return
+            end
+            par_civ1.ImageA=Field.A;%= image matrix A in the first input field 
+        end
+        if isfield(par_civ1,'ImageB')%&& (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageA),'VideoReader'))
+            [Field,ParamOut,errormsg] = read_field(par_civ1.ImageB,par_civ1.FileTypeB,[],par_civ1.FrameIndexB);
+            if ~isempty(errormsg)
+                errormsg=['error in civ_matlab/read_field:' errormsg];
+                return
+            end
+            par_civ1.ImageB=Field.A;%= image matrix A in the second input field 
         end
     end
@@ -121,5 +155,5 @@
     Data.Civ1_C=reshape(ctable,[],1);
     Data.Civ1_F=reshape(F,[],1);
-    Data.CivStage=1;  
+    Data.CivStage=1;
 else
     if exist('ncfile','var')
@@ -162,9 +196,9 @@
         Data.VarDimName=[Data.VarDimName {'nb_vec_1'}];
         nbvar=length(Data.ListVarName);
-        Data.VarAttribute{nbvar}.Role='errorflag';    
+        Data.VarAttribute{nbvar}.Role='errorflag';
         Data.Civ1_FF=fix(Param.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);
-        Data.CivStage=2;    
-    end
-end   
+        Data.CivStage=2;
+    end
+end
 %% Patch1
 if isfield (Param,'Patch1')
@@ -180,6 +214,6 @@
     nbvar=length(Data.ListVarName);
     Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
-        Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},{'nb_subdomain_1'},...
-             {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}];
+    Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},{'nb_subdomain_1'},...
+        {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}];
     Data.VarAttribute{nbvar+1}.Role='vector_x';
     Data.VarAttribute{nbvar+2}.Role='vector_y';
@@ -191,16 +225,16 @@
     if isfield(Data,'Civ1_FF')
         ind_good=find(Data.Civ1_FF==0);
-    else 
+    else
         ind_good=1:numel(Data.Civ1_X);
     end
     [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
-            filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold); 
-      fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
-      Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill);
-      Data.Civ1_U_smooth(ind_good)=Ures;
-      Data.Civ1_V_smooth(ind_good)=Vres;
-      Data.Civ1_FF(ind_good)=FFres;
-      Data.CivStage=3;                             
-end   
+        filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold);
+    fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
+    Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill);
+    Data.Civ1_U_smooth(ind_good)=Ures;
+    Data.Civ1_V_smooth(ind_good)=Vres;
+    Data.Civ1_FF(ind_good)=FFres;
+    Data.CivStage=3;
+end
 
 %% Civ2
@@ -209,5 +243,9 @@
     if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageA,par_civ2.ImageA)
         %read first image if not already done for civ1
-        [Field,ParamOut,errormsg] = read_field(par_civ2.ImageA,par_civ2.FileTypeA,[],par_civ2.i1);
+        [Field,ParamOut,errormsg] = read_field(par_civ2.ImageA,par_civ2.FileTypeA,[],par_civ2.FrameIndexA);
+                    if ~isempty(errormsg)
+                errormsg=['error in civ_matlab/read_field:' errormsg];
+                return
+            end
         par_civ2.ImageA=Field.A;
     else
@@ -216,5 +254,9 @@
     if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageB,par_civ2.ImageB)
         %read first image if not already done for civ1
-        [Field,ParamOut,errormsg] = read_field(par_civ2.ImageB,par_civ2.FileTypeB,[],par_civ2.i2);
+        [Field,ParamOut,errormsg] = read_field(par_civ2.ImageB,par_civ2.FileTypeB,[],par_civ2.FrameIndexB);
+         if ~isempty(errormsg)
+                errormsg=['error in civ_matlab/read_field:' errormsg];
+                return
+            end
         par_civ2.ImageB=Field.A;
     else
@@ -233,5 +275,5 @@
     [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
     GridX=reshape(GridX,[],1);
-    GridY=reshape(GridY,[],1); 
+    GridY=reshape(GridY,[],1);
     Shiftx=zeros(size(GridX));% shift expected from civ1 data
     Shifty=zeros(size(GridX));
@@ -270,5 +312,5 @@
     par_civ2.Shiftx=Shiftx(nbval>=1)./nbval(nbval>=1);
     par_civ2.Shifty=Shifty(nbval>=1)./nbval(nbval>=1);
-    par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors   
+    par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors
     if par_civ2.CheckDeformation
         par_civ2.DUDX=DUDX./nbval;
@@ -279,6 +321,6 @@
     % caluclate velocity data (y and v in indices, reverse to y component)
     [xtable ytable utable vtable ctable F] = civ (par_civ2);
-%     diff_squared=(utable-par_civ2.Shiftx).*(utable-par_civ2.Shiftx)+(vtable+par_civ2.Shifty).*(vtable+par_civ2.Shifty);
-%     F(diff_squared>=4)=4; %flag vectors whose distance to the guess exceeds 2 pixels
+    %     diff_squared=(utable-par_civ2.Shiftx).*(utable-par_civ2.Shiftx)+(vtable+par_civ2.Shifty).*(vtable+par_civ2.Shifty);
+    %     F(diff_squared>=4)=4; %flag vectors whose distance to the guess exceeds 2 pixels
     list_param=(fieldnames(Param.Civ2))';
     list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
@@ -300,6 +342,6 @@
     end
     Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param {'Civ2_Time','Civ2_Dt'}];
-%     Data.Civ2_Time=par_civ2.Time;
-%     Data.Civ2_Dt=par_civ2.Dt;
+    %     Data.Civ2_Time=par_civ2.Time;
+    %     Data.Civ2_Dt=par_civ2.Dt;
     nbvar=numel(Data.ListVarName);
     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
@@ -340,10 +382,10 @@
         Data.VarDimName=[Data.VarDimName {'nb_vec_2'}];
         nbvar=length(Data.ListVarName);
-        Data.VarAttribute{nbvar}.Role='errorflag';    
+        Data.VarAttribute{nbvar}.Role='errorflag';
         Data.Civ2_FF=fix(Param.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V);
-        Data.CivStage=Data.CivStage+1;    
+        Data.CivStage=Data.CivStage+1;
     end
     
-end   
+end
 
 %% Patch2
@@ -356,7 +398,7 @@
     Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbSites','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
     Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},...
-             {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
-
-        Data.VarAttribute{nbvar+1}.Role='vector_x';
+        {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
+    
+    Data.VarAttribute{nbvar+1}.Role='vector_x';
     Data.VarAttribute{nbvar+2}.Role='vector_y';
     Data.VarAttribute{nbvar+5}.Role='coord_tps';
@@ -369,14 +411,14 @@
     else
         ind_good=1:numel(Data.Civ2_X);
-    end 
+    end
     [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
-         filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold); 
-           fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
-      Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill);
+        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold);
+    fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
+    Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill);
     Data.Civ2_U_smooth(ind_good)=Ures;
     Data.Civ2_V_smooth(ind_good)=Vres;
     Data.Civ2_FF(ind_good)=FFres;
-    Data.CivStage=Data.CivStage+1;                             
-end  
+    Data.CivStage=Data.CivStage+1;
+end
 
 %% write result in a netcdf file if requested
Index: /trunk/src/find_file_series.m
===================================================================
--- /trunk/src/find_file_series.m	(revision 434)
+++ /trunk/src/find_file_series.m	(revision 435)
@@ -52,5 +52,5 @@
 % ifile_min=1;%default
 [FileType,FileInfo,Object]=get_file_type(fullfileinput);
-if strcmp( FileType,'multimage')||strcmp( FileType,'video')
+if strcmp( FileType,'multimage')||strcmp( FileType,'video')||strcmp( FileType,'mmreader')
     NomType='*';
     i1_series=(1:FileInfo.NumberOfFrames)';
Index: /trunk/src/get_file_type.m
===================================================================
--- /trunk/src/get_file_type.m	(revision 434)
+++ /trunk/src/get_file_type.m	(revision 435)
@@ -74,4 +74,8 @@
                         FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames');
                         FileType='video';
+                    elseif exist('mmreader.m','file')% Matlab 2009a
+                        VideoObject=mmreader(fileinput);
+                        FileInfo.NumberOfFrames=get(VideoObject,'NumberOfFrames');
+                        FileType='mmreader';
                     end             
                 end
Index: /trunk/src/read_field.m
===================================================================
--- /trunk/src/read_field.m	(revision 434)
+++ /trunk/src/read_field.m	(revision 435)
@@ -150,9 +150,9 @@
 % %             ParamOut.FieldList={'get_field...'};
 %         end    
-    case 'video'
+    case {'video','mmreader'}
         try
             A=read(ObjectName,num);
         catch ME
-            errormsg=ME.message
+            errormsg=ME.message;
             return
         end
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 434)
+++ /trunk/src/uvmat.m	(revision 435)
@@ -1528,5 +1528,5 @@
 UvData=get(handles.uvmat,'UserData');
 
-while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
+while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
         errormsg=runpm(hObject,eventdata,handles,increment);
         if ~isempty(errormsg)
@@ -1555,5 +1555,5 @@
 UvData=get(handles.uvmat,'UserData');
 
-while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
+while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
         errormsg=runpm(hObject,eventdata,handles,increment);
         if ~isempty(errormsg)
@@ -2034,5 +2034,5 @@
                 end
             end
-        case 'video'
+        case {'video','mmreader'}
             ObjectName=UvData.MovieObject{1};         
         case 'vol' %TODO: update
@@ -2094,5 +2094,5 @@
                 end
             end
-        case 'video'
+        case {'video','mmreader'}
             Name=UvData.MovieObject{2};
         case 'vol' %TODO: update
@@ -2406,12 +2406,10 @@
 
 %% get bounds and mesh (needed for mouse action and to open set_object)
-XName=''; %default
-YName='';
-if ~isempty(VarType{imax}.coord_x)
-    XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
-    DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
-    nbpoints_x=DimValue(DimIndex(NbDim));
-      %unstructured coordinates
-    if ~isempty(VarType{imax}.coord_y)  
+if NbDim>1
+    XName=''; %default
+    YName='';
+    %unstructured coordinates
+    if ~isempty(VarType{imax}.coord_x)&&~isempty(VarType{imax}.coord_y)
+        XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
         YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
         %nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors)
@@ -2422,131 +2420,132 @@
             NbDim=2;
         end
-    end
-%structured coordinate   
-elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 
-    XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
-    if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
-        YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
-    end
-   % VarIndex=CellVarIndex{imax}; % list of variable indices
-    DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
-    nbpoints_x=DimValue(DimIndex(NbDim));
-    XMax=nbpoints_x;%default
-    XMin=1;%default
-end
-
-if NbDim==3
-    if ~test_x
-        ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
-    end
-    ZMax=max(UvData.Field.(ZName));
-    ZMin=min(UvData.Field.(ZName));
-    UvData.Field.ZMax=ZMax;
-    UvData.Field.ZMin=ZMin;
-    test_z=1;
-    if isequal(ZMin,ZMax)%no z dependency
-        NbDim=2;
-        test_z=0;
-    end
-end
-if ~isempty (XName)
-    XMax=max(max(UvData.Field.(XName)));
-    XMin=min(min(UvData.Field.(XName)));
-    UvData.Field.NbDim=NbDim;
-    UvData.Field.XMax=XMax;
-    UvData.Field.XMin=XMin;
-    if NbDim >1&& ~isempty(YName)
-        YMax=max(max(UvData.Field.(YName)));
-        YMin=min(min(UvData.Field.(YName)));
-        UvData.Field.YMax=YMax;
-        UvData.Field.YMin=YMin; 
-    end
-    nbvec=length(UvData.Field.(XName));
-    if test_x %unstructured coordinates
-        if test_z
-            UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
-            UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
-        else
-            UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
-        end
-    end
-end
-% case of structured coordinates
-if ~test_x
-    DX=(XMax-XMin)/(nbpoints_x-1);
-    if NbDim >1
-        nbpoints_y=DimValue(DimIndex(NbDim-1));
-        if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index
-            DY=1;
-            UvData.Field.YMax=nbpoints_y;
-            UvData.Field.YMin=1;
-        else
-            DY=(YMax-YMin)/(nbpoints_y-1);
-        end
-    end
+        %structured coordinate
+    elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0
+        XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
+        if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
+            YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
+        end
+        % VarIndex=CellVarIndex{imax}; % list of variable indices
+        DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
+        nbpoints_x=DimValue(DimIndex(NbDim));
+        XMax=nbpoints_x;%default
+        XMin=1;%default
+    end
+    
     if NbDim==3
-        nbpoints_z=DimValue(DimIndex(1));
-        DZ=(ZMax-ZMin)/(nbpoints_z-1);
-        UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
+        if ~test_x
+            ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
+        end
+        ZMax=max(UvData.Field.(ZName));
+        ZMin=min(UvData.Field.(ZName));
         UvData.Field.ZMax=ZMax;
         UvData.Field.ZMin=ZMin;
+        test_z=1;
+        if isequal(ZMin,ZMax)%no z dependency
+            NbDim=2;
+            test_z=0;
+        end
+    end
+    if ~isempty (XName)
+        XMax=max(max(UvData.Field.(XName)));
+        XMin=min(min(UvData.Field.(XName)));
+        UvData.Field.NbDim=NbDim;
+        UvData.Field.XMax=XMax;
+        UvData.Field.XMin=XMin;
+        if NbDim >1&& ~isempty(YName)
+            YMax=max(max(UvData.Field.(YName)));
+            YMin=min(min(UvData.Field.(YName)));
+            UvData.Field.YMax=YMax;
+            UvData.Field.YMin=YMin;
+        end
+        nbvec=length(UvData.Field.(XName));
+        if test_x %unstructured coordinates
+            if test_z
+                UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
+                UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
+            else
+                UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
+            end
+        end
+    end
+    % case of structured coordinates
+    if ~test_x
+        DX=(XMax-XMin)/(nbpoints_x-1);
+        if NbDim >1
+            nbpoints_y=DimValue(DimIndex(NbDim-1));
+            if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index
+                DY=1;
+                UvData.Field.YMax=nbpoints_y;
+                UvData.Field.YMin=1;
+            else
+                DY=(YMax-YMin)/(nbpoints_y-1);
+            end
+        end
+        if NbDim==3
+            nbpoints_z=DimValue(DimIndex(1));
+            DZ=(ZMax-ZMin)/(nbpoints_z-1);
+            UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
+            UvData.Field.ZMax=ZMax;
+            UvData.Field.ZMin=ZMin;
+        else
+            UvData.Field.Mesh=DX;%sqrt(DX*DY);
+        end
+    end
+    % adjust the mesh to a value 1, 2 , 5 *10^n
+    ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
+    if UvData.Field.Mesh/ord>=5
+        UvData.Field.Mesh=5*ord;
+    elseif UvData.Field.Mesh/ord>=2
+        UvData.Field.Mesh=2*ord;
     else
-        UvData.Field.Mesh=DX;%sqrt(DX*DY);
-    end
-end
-% adjust the mesh to a value 1, 2 , 5 *10^n
-ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
-if UvData.Field.Mesh/ord>=5
-    UvData.Field.Mesh=5*ord;
-elseif UvData.Field.Mesh/ord>=2
-    UvData.Field.Mesh=2*ord;
-else
-    UvData.Field.Mesh=ord;
-end
-UvData.Object{1}.Type='plane';%main plotting plane
-UvData.Object{1}.ProjMode='projection';%main plotting plane
-UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
-UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
-
-%% 3D case (menuvolume)
-if NbDim==3% && UvData.NewSeries
-    test_set_object=1;
-    hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
-    ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
-    ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
-    if ~isempty(hset_object) %if set_object is detected
-          delete(hset_object);% delete the GUI set_object if it does not fit 
-    end
-    if test_set_object% reinitiate the GUI set_object
-        delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
-        UvData.Object{1}.NbDim=NbDim;%test for 3D objects
-        UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
-        UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
-        UvData.Object{1}.Angle=[0 0 0];
-        UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
-        UvData.Object{1}.Name='1-PLANE';
-        UvData.Object{1}.enable_plot=1;
-        set_object(UvData.Object{1},handles,ZBounds);
-        set(handles.ListObject,'Value',1);
-        set(handles.ListObject,'String',{'1-PLANE'});
-        set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
-        edit_object_Callback([],[], handles)
-    end
-    %multilevel case (single menuplane in a 3D space)
-elseif isfield(UvData,'Z')
-    if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
-        XmlData=UvData.XmlData{1};
-        if isfield(XmlData,'PlanePos')
-            UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
-        end
-        if isfield(XmlData,'PlaneAngle')
-            siz=size(XmlData.PlaneAngle);
-            indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
-            UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
-        end
-    elseif isfield(UvData,'ZIndex')
-        UvData.Object{1}.ZObject=UvData.ZIndex;
-    end
-end
+        UvData.Field.Mesh=ord;
+    end
+    UvData.Object{1}.Type='plane';%main plotting plane
+    UvData.Object{1}.ProjMode='projection';%main plotting plane
+    UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
+    UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
+    
+    %% 3D case (menuvolume)
+    if NbDim==3% && UvData.NewSeries
+        test_set_object=1;
+        hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
+        ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
+        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
+        if ~isempty(hset_object) %if set_object is detected
+            delete(hset_object);% delete the GUI set_object if it does not fit
+        end
+        if test_set_object% reinitiate the GUI set_object
+            delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
+            UvData.Object{1}.NbDim=NbDim;%test for 3D objects
+            UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
+            UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
+            UvData.Object{1}.Angle=[0 0 0];
+            UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
+            UvData.Object{1}.Name='1-PLANE';
+            UvData.Object{1}.enable_plot=1;
+            set_object(UvData.Object{1},handles,ZBounds);
+            set(handles.ListObject,'Value',1);
+            set(handles.ListObject,'String',{'1-PLANE'});
+            set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
+            edit_object_Callback([],[], handles)
+        end
+        %multilevel case (single menuplane in a 3D space)
+    elseif isfield(UvData,'Z')
+        if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
+            XmlData=UvData.XmlData{1};
+            if isfield(XmlData,'PlanePos')
+                UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
+            end
+            if isfield(XmlData,'PlaneAngle')
+                siz=size(XmlData.PlaneAngle);
+                indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
+                UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
+            end
+        elseif isfield(UvData,'ZIndex')
+            UvData.Object{1}.ZObject=UvData.ZIndex;
+        end
+    end
+end
+
 testnewseries=UvData.NewSeries;
 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
