Index: trunk/src/get_file_series.m
===================================================================
--- trunk/src/get_file_series.m	(revision 599)
+++ trunk/src/get_file_series.m	(revision 635)
@@ -20,17 +20,21 @@
 incr_i=Param.IndexRange.incr_i;
 last_i=Param.IndexRange.last_i;
-ref_i=first_i:incr_i:last_i;
-ref_j=[];
+% ref_i=first_i:incr_i:last_i;
+%ref_j=[];
+first_j=[];last_j=[];incr_j=1;%default
 if isfield(Param.IndexRange,'first_j')
     first_j=Param.IndexRange.first_j;
     incr_j=Param.IndexRange.incr_j;
     last_j=Param.IndexRange.last_j;
-    ref_j=first_j:incr_j:last_j;
 end
 
 %% determine the list of input file names
 nbmissing=0;
-
-for iview=1:size(InputTable,1)
+NbView=size(InputTable,1);
+i1_series=cell(NbView,1);% initiate index series with empty cells
+i2_series=cell(NbView,1);
+j1_series=cell(NbView,1);
+j2_series=cell(NbView,1);
+for iview=1:NbView
     r.mode='';
     if isfield (Param.IndexRange,'PairString')
@@ -38,7 +42,7 @@
             Param.IndexRange.PairString={Param.IndexRange.PairString};
         end
-        r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');
+        r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');%look for mode=Dj or Di
         if isempty(r)
-            r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');
+            r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');%look for burst pairs
         end
         % TODO case of free pairs:
@@ -51,23 +55,53 @@
             r(1).mode='*-*';
         else
-        r(1).mode='';
+            r(1).mode='';
         end
     end
-    if isequal(r(1).mode,'*-*')% free pairs
+   
+    if isempty(incr_i) || isempty(incr_j) || isequal(r(1).mode,'*-*')% free pairs
         FilePath=fullfile(InputTable{iview,1},InputTable{iview,2});
         fileinput=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}];
-        [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput);
-        i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %first  pair index
-        check_select=i1_series{iview}>=first_i & i1_series{iview}<=last_i;
-        i1_series{iview}=i1_series{iview}(check_select);    
-        i2_series{iview}=[]; %first  pair index
+        [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,...
+            i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput);
+        i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %select first  pair index as ordered by find_file_series
         j1_series{iview}=squeeze(j1_series{iview}(1,:,:)); %first  pair index
-        j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %first  pair index
-        j1_series{iview}=j1_series{iview}(check_select);
-        j2_series{iview}=j2_series{iview}(check_select);
+        j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %second  pair index
+        %check_select=i1_series{iview}>=first_i & i1_series{iview}<=last_i;
+        if isempty(incr_i)
+            if isempty(incr_j)
+                [ref_j,ref_i]=find(i1_series{iview});
+                ref_i=ref_i-1;
+                ref_j=ref_j-1;
+                ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
+                ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
+            else
+                ref_j=first_j:incr_j:last_j;
+                [tild,ref_i]=find(i1_series{iview}(:,ref_j));
+                ref_i=ref_i-1;
+                ref_i=ref_i(ref_i>=first_i & ref_i<=last_i);
+            end
+        else
+            ref_i=first_i:incr_i:last_i;%default
+            if isempty(incr_j)
+                [ref_j,tild]=find(i1_series{iview});
+                ref_j=ref_j-1;
+                ref_j=ref_j(ref_j>=first_j & ref_j<=last_j);
+            else
+                ref_j=first_j:incr_j:last_j;
+            end
+        end
+        i1_series{iview}=i1_series{iview}(ref_j,ref_i);
+        j1_series{iview}=j1_series{iview}(ref_j,ref_i);
+        if ~isempty(j2_series{iview})
+        j2_series{iview}=j2_series{iview}(ref_j,ref_i);
+        end
     else
+        ref_i=first_i:incr_i:last_i;%default
+        ref_j=first_j:incr_j:last_j;%default
+    end
+    if ~isequal(r(1).mode,'*-*')% imposed pairs or single i and/or j index
         [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode);
     end
-        
+    
     %case of pairs (.nc files)
     i2=[];j1=[];j2=[];
@@ -83,5 +117,5 @@
             j2=j2_series{iview}(ifile);
         end
-         filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,i2,j1,j2);
+        filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,i2,j1,j2);
     end
 end
