Index: trunk/src/civ.m
===================================================================
--- trunk/src/civ.m	(revision 427)
+++ 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 
