Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 909)
+++ /trunk/src/series.m	(revision 910)
@@ -1481,23 +1481,16 @@
 errormsg='';%default error message
 xmlfile=fullfile(path_series,'PARAM.xml');
-test_batch=0;%default: ,no batch mode available
+%test_batch=0;%default: ,no batch mode available
 if ~exist(xmlfile,'file')
     [success,message]=copyfile(fullfile(path_series,'PARAM.xml.default'),xmlfile);
 end
-% RunTime='';
 if strcmp(ActionExt,'.sh')
     if exist(xmlfile,'file')
         s=xml2struct(xmlfile);
         if strcmp(RunMode,'cluster_oar') && isfield(s,'BatchParam')
-%             if isfield(s.BatchParam,'RunTime')
-%                 RunTime=s.BatchParam.RunTime;
-%             end
             if isfield(s.BatchParam,'NbCore')
                 NbCore=s.BatchParam.NbCore;
             end
         elseif (strcmp(RunMode,'background')||strcmp(RunMode,'local')) && isfield(s,'RunParam')
-%             if isfield(s.RunParam,'RunTime')
-%                 RunTime=s.RunParam.RunTime;
-%             end
             if isfield(s.RunParam,'NbCore')
                 NbCore=s.RunParam.NbCore;
@@ -1505,8 +1498,4 @@
         end
     end
-%     if isempty(RunTime) && strcmp(RunMode,'cluster_oar')
-%        errormsg='RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster';
-%         return
-%     end
 end
 
@@ -1727,19 +1716,17 @@
 end
 nbfield_j=numel(ref_j); % number of j indices
-BlockLength=numel(ref_i);%default
-if isempty(Param.IndexRange.NbSlice)
-    NbProcess=NbCore;% choose one process per core by default if NbSlice is not imposed
-    switch RunMode
-        case 'cluster_oar'
-            BlockLength= ceil(20/(CPUTime*nbfield_j));% short iterations are grouped such that the minimum time of a process is 20 min. 
-            NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
-    end
-else
-    NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes 
-    NbCore=min(NbCore,NbProcess);% reduces the number of cores if it exceeds the number of processes
-end
-
-%BlockLength=ceil(numel(ref_i)/NbProcess);% nbre of input fields in each process 
-%nbfield_j=numel(ref_j); % number of j indices
+BlockLength=numel(ref_i);% by default, job involves the full set of i field indices 
+NbProcess=1;
+switch RunMode
+    case {'cluster_oar','cluster_pbs'}
+        if isempty(Param.IndexRange.NbSlice)% if NbSlice is not defined
+             BlockLength= ceil(20/(CPUTime*nbfield_j));% short iterations are grouped such that the minimum time of a process is 20 min.
+             BlockLength=max(BlockLength,ceil(numel(ref_i)/1000));% possibly increase the BlockLength to have less than 1000 jobs
+             NbProcess=ceil(numel(ref_i)/BlockLength) ; % nbre of processes sent to oar
+        else
+            NbProcess=Param.IndexRange.NbSlice;% the parameter NbSlice sets the nbre of run processes
+            NbCore=min(NbCore,NbProcess);% reduces the number of cores if it exceeds the number of processes
+        end
+end
 
 %% record nbre of output files and starting time for computation for status
Index: /trunk/src/series/civ_input.m
===================================================================
--- /trunk/src/series/civ_input.m	(revision 909)
+++ /trunk/src/series/civ_input.m	(revision 910)
@@ -130,6 +130,8 @@
             return
         end
+        if isfield(Data,'.Civ1_ImageA')
         [PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);%look for the source image A
         [PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);%look for the source image B
+        end
         if isfield(Data,'Civ2_ImageA')
             [PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA);
@@ -137,8 +139,15 @@
         end
         if size(Param.InputTable,1)==1
+             if isfield(Data,'.Civ1_ImageA')
             series('display_file_name',hhseries,Data.Civ1_ImageA,'append');%append the image series to the input list
-        end
-        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);
+                    [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);
         [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB);
+             else
+                 series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list
+                         [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA);
+        [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ2_ImageB);
+             end
+        end
+
         iview_image=2;%line # for the input images
     case 'civxdata'% case of  civx data,
Index: /trunk/src/series/civ_series.m
===================================================================
--- /trunk/src/series/civ_series.m	(revision 909)
+++ /trunk/src/series/civ_series.m	(revision 910)
@@ -1024,4 +1024,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;
             else
                 image1_crop=image1_crop.*~mask1_crop;% put to zero the masked pixels (mask1_crop='true'=1)
@@ -1042,5 +1044,8 @@
                 F(ivec)=3;
             end
-            if F(ivec)~=3
+            if F(ivec)==3
+                utable(ivec)=0;
+                vtable(ivec)=0;
+            else
                 %mask
                 if checkmask
@@ -1099,4 +1104,5 @@
                     catch ME
                         F(ivec)=3;
+                        disp(ME.message)
                     end
                 else
@@ -1127,5 +1133,5 @@
 %http://urapiv.wordpress.com
 peaky = y;
-if y <= npy-1 && y >= 1
+if y <= npy-1 && y > 1
     f0 = log(result_conv(y,x));
     f1 = log(result_conv(y-1,x));
@@ -1136,5 +1142,5 @@
 end
 peakx=x;
-if x <= npx-1 && x >= 1
+if x <= npx-1 && x > 1
     f0 = log(result_conv(y,x));
     f1 = log(result_conv(y,x-1));
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 909)
+++ /trunk/src/uvmat.m	(revision 910)
@@ -1469,6 +1469,6 @@
     flag=1;
     if ~isfield(UvData.Field,'A')
-            msgbox_uvmat('ERROR','an image needs to be opened to set the mask size');
-    return
+        msgbox_uvmat('ERROR','an image needs to be opened to set the mask size');
+        return
     end
     npx=size(UvData.Field.A,2);
@@ -1477,62 +1477,62 @@
     yi=0.5:npy-0.5;
     [Xi,Yi]=meshgrid(xi,yi);
-        for iobj=1:length(UvData.ProjObject)
-            ObjectData=UvData.ProjObject{iobj};
-            if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
-                flagobj=1;
-                testphys=0; %coordinates in pixels by default
-                if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
-                    if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib')
-                        Calib=UvData.XmlData{1}.GeometryCalib;
-                        testphys=1;
+    for iobj=1:length(UvData.ProjObject)
+        ObjectData=UvData.ProjObject{iobj};
+        if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
+            flagobj=1;
+            testphys=0; %coordinates in pixels by default
+            if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
+                if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib')
+                    Calib=UvData.XmlData{1}.GeometryCalib;
+                    testphys=1;
+                end
+            end
+            if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type')
+                if isequal(ObjectData.Type,'polygon')
+                    X=ObjectData.Coord(:,1);
+                    Y=ObjectData.Coord(:,2);
+                    if testphys
+                        pos=[X Y zeros(size(X))];
+                        if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3
+                            if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0])
+                                om=norm(Calib.SliceAngle);%norm of rotation angle in radians
+                                OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis
+                                cos_om=cos(pi*om/180);
+                                sin_om=sin(pi*om/180);
+                                pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
+                            end
+                            pos(:,1)=pos(:,1)+Calib.SliceCoord(1);
+                            pos(:,2)=pos(:,2)+Calib.SliceCoord(2);
+                            pos(:,3)=pos(:,3)+Calib.SliceCoord(3);
+                        end
+                        [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3));
                     end
+                    flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
+                elseif isequal(ObjectData.Type,'ellipse')
+                    if testphys
+                        %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
+                    end
+                    RangeX=max(ObjectData.RangeX);
+                    RangeY=max(ObjectData.RangeY);
+                    X2Max=RangeX*RangeX;
+                    Y2Max=RangeY*RangeY;
+                    distX=(Xi-ObjectData.Coord(1,1));
+                    distY=(Yi-ObjectData.Coord(1,2));
+                    flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
+                elseif isequal(ObjectData.Type,'rectangle')
+                    if testphys
+                        %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
+                    end
+                    distX=abs(Xi-ObjectData.Coord(1,1));
+                    distY=abs(Yi-ObjectData.Coord(1,2));
+                    flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
                 end
-                if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type')
-                    if isequal(ObjectData.Type,'polygon')
-                        X=ObjectData.Coord(:,1);
-                        Y=ObjectData.Coord(:,2);
-                        if testphys
-                            pos=[X Y zeros(size(X))];
-                            if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3
-                                if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0])
-                                    om=norm(Calib.SliceAngle);%norm of rotation angle in radians
-                                    OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis
-                                    cos_om=cos(pi*om/180);
-                                    sin_om=sin(pi*om/180);
-                                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
-                                end
-                                pos(:,1)=pos(:,1)+Calib.SliceCoord(1);
-                                pos(:,2)=pos(:,2)+Calib.SliceCoord(2);
-                                pos(:,3)=pos(:,3)+Calib.SliceCoord(3);
-                            end                           
-                            [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3));
-                        end
-                        flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
-                    elseif isequal(ObjectData.Type,'ellipse')
-                        if testphys
-                            %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
-                        end
-                        RangeX=max(ObjectData.RangeX);
-                        RangeY=max(ObjectData.RangeY);
-                        X2Max=RangeX*RangeX;
-                        Y2Max=RangeY*RangeY;
-                        distX=(Xi-ObjectData.Coord(1,1));
-                        distY=(Yi-ObjectData.Coord(1,2));
-                        flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
-                    elseif isequal(ObjectData.Type,'rectangle')
-                        if testphys
-                            %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
-                        end
-                        distX=abs(Xi-ObjectData.Coord(1,1));
-                        distY=abs(Yi-ObjectData.Coord(1,2));
-                        flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
-                    end
-                    if isequal(ObjectData.ProjMode,'mask_outside')
-                        flagobj=~flagobj;
-                    end
-                    flag=flag & flagobj;
+                if isequal(ObjectData.ProjMode,'mask_outside')
+                    flagobj=~flagobj;
                 end
-            end
-        end
+                flag=flag & flagobj;
+            end
+        end
+    end
     %mask name
     RootPath=get(handles.RootPath,'String');
@@ -1548,5 +1548,5 @@
     imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
     imflag=flipdim(imflag,1);
-
+    
     %display the mask
     hfigmask=figure;
@@ -1570,5 +1570,9 @@
             end
         end
-        imwrite(imflag,answer,'BitDepth',8);
+        try
+            imwrite(imflag,answer,'BitDepth',8);
+        catch ME
+            msgbox_uvmat('ERROR',ME.message)
+        end
     end
     set(handles.ListObject,'Value',1)
