Index: trunk/src/series/civ_series.m
===================================================================
--- trunk/src/series/civ_series.m	(revision 633)
+++ trunk/src/series/civ_series.m	(revision 635)
@@ -79,6 +79,11 @@
 %% input files and indexing
 NbField=1;
-MaxIndex=cell2mat(Param.IndexRange.MaxIndex);
-MinIndex=cell2mat(Param.IndexRange.MinIndex);
+MaxIndex_i=Param.IndexRange.MaxIndex_i;
+MinIndex_i=Param.IndexRange.MinIndex_i;
+MaxIndex_j=1;MinIndex_j=1;
+if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j')
+    MaxIndex_j=Param.IndexRange.MaxIndex_j;
+    MinIndex_j=Param.IndexRange.MinIndex_j;
+end
 if isfield(Param,'InputTable')
     [filecell,i_series,tild,j_series]=get_file_series(Param);
@@ -120,5 +125,5 @@
     if iview_B==0
         FileType_B=FileType_A;
-VideoObject_B=VideoObject_A;
+        VideoObject_B=VideoObject_A;
         PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1;
         PairCiv2='';
@@ -127,8 +132,8 @@
         end
         [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
-            find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex,MaxIndex);
+            find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
         if ~isempty(PairCiv2)
             [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=...
-                find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex,MaxIndex);
+                find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j);
             check_bounds=check_bounds | check_bounds_Civ2;
         end
@@ -158,8 +163,8 @@
         end
     else
-           [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1});
+        [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1});
         if isempty(find(strcmp(FileType_B,{'multimage','mmreader','video'})))
             displ(['ERROR: the file line ' num2str(iview_B) ' must be an image'])
-        end   
+        end
         %TODO : introduce the second file series if relevant: case %displacement
     end
@@ -217,6 +222,6 @@
 %%%%% MAIN LOOP %%%%%%
 for ifield=1:NbField
-    update_waitbar(WaitbarHandle,index/nbfield)
-    if ~isempty(RUNHandle) && ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
+    update_waitbar(WaitbarHandle,ifield/NbField)
+    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
         disp('program stopped by user')
         break
@@ -264,6 +269,6 @@
             j2=j2_series_Civ1(ifield);
         end
-        Data.Civ1_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;
-        Data.Civ1_Dt=time(i2+1,j2+1)-time(i1+1,j1+1);
+        Data.Civ1_Time=(time(j2+1,i2+1)+time(j1+1,i1+1))/2;
+        Data.Civ1_Dt=time(j2+1,i2+1)-time(j1+1,i1+1);
         for ilist=1:length(list_param)
             Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist});
@@ -400,8 +405,8 @@
         ImageName_A_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series_Civ2(ifield),[],j1_series_Civ2(ifield));
 
-        if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2)
+        if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield))
             par_civ2.ImageA=par_civ1.ImageA;
         else
-            [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2);
+            [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield));
         end
         ImageName_B_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ2(ifield),[],j2_series_Civ2(ifield));
@@ -409,11 +414,11 @@
             par_civ2.ImageB=par_civ1.ImageB;
         else
-            [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2);
+            [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield));
         end     
         
         ncfile=fullfile_uvmat(RootPath,OutputDir,RootFile,'.nc',NomTypeNc,i1_series_Civ2(ifield),i2_series_Civ2(ifield),...
             j1_series_Civ2(ifield),j2_series_Civ2(ifield));
-        par_civ2.ImageWidth=FileInfo.Width;
-        par_civ2.ImageHeight=FileInfo.Height;
+        par_civ2.ImageWidth=FileInfo_A.Width;
+        par_civ2.ImageHeight=FileInfo_A.Height;
         
         if isfield(par_civ2,'Grid')% grid points set as input file
@@ -935,5 +940,5 @@
 % --- determine the list of index pairs of processing file
 function [i1_series,i2_series,j1_series,j2_series,check_bounds,NomTypeNc]=...
-    find_pair_indices(str_civ,i_series,j_series,MinIndex,MaxIndex)
+    find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j)
 %------------------------------------------------------------------------
 i1_series=i_series;% set of first image indexes
@@ -973,5 +978,5 @@
     i1_series=i_series-ind1;% set of first image numbers
     i2_series=i_series+ind2;
-    check_bounds=i1_series<MinIndex(1,1) | i2_series>MaxIndex(1,1);
+     check_bounds=i1_series<MinIndex_i | i2_series>MaxIndex_i;
     if isempty(j_series)
         NomTypeNc='_1-2';
@@ -984,5 +989,5 @@
     j1_series=j_series-ind1;
     j2_series=j_series+ind2;
-    check_bounds=j1_series<MinIndex(1,2) | j2_series>MaxIndex(1,2);
+    check_bounds=j1_series<MinIndex_j | j2_series>MaxIndex_j;
     NomTypeNc='_1_1-2';
 else  %bursts
