Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 397)
+++ /trunk/src/civ.m	(revision 398)
@@ -395,12 +395,17 @@
 
 %% scan the image file series 
-[RootPath,FileName,ImaExt]=fileparts(fileinput);
-[RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object]=find_file_series(RootPath,[FileName ImaExt]);
-if strcmp(NomTypeInput,'*')% movies will be opened at the first frame
-    i1=1;
-    i2=[];
-    j1=[];
-    j2=[];
-end
+[FilePath,FileName,ImaExt]=fileparts(fileinput);
+% detect the file type, get the movie object if relevant, and look for the corresponding file series:
+% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
+[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomTypeIma,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName ImaExt]);
+
+% [RootPath,FileName,ImaExt]=fileparts(fileinput);
+% [RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,Object]=find_file_series(RootPath,[FileName ImaExt]);
+% if strcmp(NomTypeInput,'*')% movies will be opened at the first frame
+%     i1=1;
+%     i2=[];
+%     j1=[];
+%     j2=[];
+% end
 switch FileType
     case {'image','multimage','video'}
@@ -427,7 +432,4 @@
 
 %% scan the images if a civ file has been opened
-% if ~isempty(NomTypeNc)
-% [tild,i1_series,tild,j1_series,tild,NomTypeIma,ImageType,Object]=find_file_series(RootPath,RootFile);
-% end
 MinIndex_i=min(i1_series(i1_series>0));
 MinIndex_j=min(j1_series(j1_series>0));
@@ -2695,6 +2697,11 @@
         [tild,RootFile_1]=fileparts(name);
     else
-        [tild,tild,RootFile_1,tild,tild,tild,tild,tild,nom_type_1]=fileparts_uvmat(fileinput);
-        [RootFile_1,i1_series,tild,j1_series,tild,nom_type_1,FileType,Object]=find_file_series(PathName,FileName);
+        [FilePath,FileName,Ext]=fileparts(fileinput);
+% detect the file type, get the movie object if relevant, and look for the corresponding file series:
+% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
+[RootPath,SubDir,RootFile_1,i1_series,i2_series,j1_series,j2_series,nom_type_1,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName Ext]);
+        
+       % [tild,tild,RootFile_1,tild,tild,tild,tild,tild,nom_type_1]=fileparts_uvmat(fileinput);
+        %[RootFile_1,i1_series,tild,j1_series,tild,nom_type_1,FileType,Object]=find_file_series(PathName,FileName);
         %check image nom type 
         if ~strcmp(nom_type_1,get(handles.NomType,'String'))
Index: /trunk/src/find_file_series.m
===================================================================
--- /trunk/src/find_file_series.m	(revision 397)
+++ /trunk/src/find_file_series.m	(revision 398)
@@ -1,5 +1,5 @@
 %'find_file_series': check the content of an input file and find the corresponding file series
 %--------------------------------------------------------------------------
-% function [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(fileinput)
+% function [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(fileinput)
 %
 % OUTPUT:
@@ -37,12 +37,11 @@
 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 
-function [RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPath,fileinput)
+function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
 %------------------------------------------------------------------------
-if ~exist('option','var')
-    option='all';
-end
+
 %% get input root name and nomenclature type
-[tild,tild,RootFile,tild,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fileinput);
-fullfileinput=fullfile(RootPath,fileinput);% input file name with path
+fullfileinput=fullfile(FilePath,fileinput);% input file name with path
+[RootPath,SubDir,RootFile,i1_input,i2_input,j1_input,j2_input,FileExt,NomType]=fileparts_uvmat(fullfileinput);
+
 
 %% check for particular file types: images, movies, civ data
@@ -58,21 +57,18 @@
 end
 
-if strcmp(NomType,'')||strcmp(NomType,'*')||strcmp(option,'filetype')
+if strcmp(NomType,'')||strcmp(NomType,'*')
     if exist(fullfileinput,'file')
-      %  RootFile=fileinput;% case of constant name (no indexing)
-        [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing)
+        [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing), get the filename without its extension
     else
         RootFile='';
     end
+    i1_input=1;% the index now refer to the frame in the movie, choose 1 at opening
+    i2_input=[];
+    j1_input=[];
+    j2_input=[];
 else
     %% possibly include the first index in the root name, if there exists a corresponding xml file
-    %   RootFileNew=RootFile;
-    %     if ~isempty(regexp(NomType,['^_']))
-    %         NomTypePref='_';
-    %         RootFileNew=[RootFileNew '_'];
-    %     end       RootPath='';
     NomTypePref='';
     r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType
-    %     r=regexp(NomType,['^' NomTypePref '(?<num1>\d+)'],'names');%look for a number at the beginning of NomTypeSt
     if ~isempty(r)
         fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
@@ -85,8 +81,9 @@
             RootFileNew=[RootFile rr.i1];
             checkpair=~isempty(regexp(NomType,'-','once'))||~isempty(regexp(NomType,'ab$','once'))||~isempty(regexp(NomType,'AB$','once'));%case of PIV results
-            if exist(fullfile(RootPath,[RootFileNew '.xml']),'file') || (checkpair && exist(fullfile(fileparts(RootPath),[RootFileNew '.xml']),'file'))
+            if exist(fullfile(RootPath,[RootFileNew '.xml']),'file') %|| (checkpair && exist(fullfile(fileparts(RootPath),[RootFileNew '.xml']),'file'))
                 RootFile=RootFileNew;
                 NomTypePref=r.tiretnum;
                 NomType=regexprep(NomType,['^'  NomTypePref],'');
+                i1_input=j1_input;
                 i2_input=j2_input;
                 j1_input=[];
@@ -151,5 +148,5 @@
     star_string=[RootFile sep1 i1_star i2_star  j1_star j2_star FileExt];
     wd=pwd;%current working directory
-    cd (RootPath)% move to the local dir to save time in the operation dir.
+    cd (FilePath)% move to the local dir to save time in the operation dir.
     dirpair=dir(star_string);% look for relevant files in the file directory
     cd(wd)
@@ -158,5 +155,4 @@
     ref_j_list=zeros(1,nbpair);
     if nbpair==0% no detected file
-        %         RootPath='';
         RootFile='';
     end
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 397)
+++ /trunk/src/series.m	(revision 398)
@@ -957,64 +957,4 @@
 ind_shift=0;%default
 
-%determine the list of input file names
-nbmissing=0;
-% for iview=1:length(RootPath)
-%     %case of pairs (.nc files)
-%     fileinput=name_generator(fullfile(RootPath{iview},RootFile{iview}),first_i,first_j,FileExt{iview},NomType{iview},1,first_i+1,first_j+1,SubDir{iview});
-%     if strcmp(get(handles.Pairs,'Visible'),'on')
-%        pair_list=get(handles.list_pair_civ,'String');
-%        val=get(handles.list_pair_civ,'Value');
-%        pair_string=pair_list{val};
-%        r=regexp(pair_string,'.*\D(?<num1>[\d+|*])(?<delim>[-||])(?<num2>[\d+|*])','names');
-%        if ~isempty(r)
-%            if strcmp(r.num1,'*')%free pairs
-%                [tild,RootFile,i1_series,i2_series,j1_series,j2_series,tild,tild,Object]=find_file_series(fileinput);% TODO: choice pair when multiple choice
-%  
-%                if isempty(i2_series) %j pairs
-%                    ind_sel=i1_series>=i1_series>=first_i & i1_series<=last_i & j1_series>first_j & j2_series<last_j;
-%                    j2_series=j2_series(ind_sel);
-%                else%i pairs
-%                    if isempty(j1_series) %j pairs
-%                         ind_sel=i1_series>=first_i & i2_series<=last_i ;
-%                    else
-%                        ind_sel=i1_series>=first_i & i2_series<=last_i& j1_series>first_j & j1_series<last_j; 
-%                        j1_series=j1_series(ind_sel);
-%                        i2_series=i2_series(ind_sel);
-%                    end
-%                end
-%                i1_series=i1_series(ind_sel);             
-%            else
-%                if strcmp(r.delim,'-')
-%                    ind_shift(1)=str2num(r.num1);
-%                    ind_shift(2)=str2num(r.num2);
-%                else
-%                    ind_shift(1)=-str2num(r.num1);
-%                    ind_shift(2)=str2num(r.num2);
-%                end
-%                [i1_series,i2_series,j1_series,j2_series,nbmissing]=find_file_indices(num_i,num_j,ind_shift,NomType{iview},mode);
-%            end
-%        end
-%        if isempty(i1_series)
-%            msgbox_uvmat('ERROR','no file in the considered range')
-%            return
-%        end
-%        if isempty(i2_series)
-%            i2_series=i1_series;
-%        end
-%        if isempty(j2_series)
-%            j2_series=j1_series;
-%        end 
-%     else%case of images
-%         [i1_series,j1_series]=meshgrid(num_i,num_j);
-%         i2_series=i1_series;
-%         j2_series=j1_series;
-%     end
-%     if length(RootPath)>1
-%         i1_series_cell{iview}=i1_series;
-%         i2_series_cell{iview}=i2_series;
-%         j1_series_cell{iview}=j1_series;
-%         j2_series_cell{iview}=j2_series;
-%     end
-% end
 
 %% defining the ACTION function handle
@@ -1829,11 +1769,17 @@
 %% look for min and max indices existing in the file series and update SeriesData
 errormsg='';
-[RootPathSub,FileName,FileExt]=fileparts(fileinput);
-[RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPathSub,[FileName FileExt]);
+[FilePath,FileName,FileExt]=fileparts(fileinput);
+% detect the file type, get the movie object if relevant, and look for the corresponding file series:
+% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
+[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
+
+% 
+% [RootPathSub,FileName,FileExt]=fileparts(fileinput);
+% [RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,Object]=find_file_series(RootPathSub,[FileName FileExt]);
 if isempty(RootFile)&&isempty(i1_series)
     errormsg='no input file in the series';
     return
 end
-[tild,tild,FileExt]=fileparts(fileinput);
+% [tild,tild,FileExt]=fileparts(fileinput);
 
 MinIndex=get(handles.MinIndex,'Data');
@@ -1968,5 +1914,5 @@
 %%  read image documentation file  if found%%%%%%%%%%%%%%%%%%%%%%%%%%%
 ext_imadoc='';
-FileBase=fullfile(RootPathSub,RootFile);
+FileBase=fullfile(RootPath,RootFile);
 if isequal(FileExt,'.xml')||isequal(FileExt,'.civ')
     ext_imadoc=FileExt;
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 397)
+++ /trunk/src/uvmat.m	(revision 398)
@@ -504,14 +504,15 @@
 
 %% detect root name, nomenclature and indices in the input file name:
-[RootPath,SubDir,tild,i1,i2,j1,j2]=fileparts_uvmat(fileinput);
-[tild,FileName,FileExt]=fileparts(fileinput);
+%[RootPath,SubDir]=fileparts_uvmat(fileinput);
+[FilePath,FileName,FileExt]=fileparts(fileinput);
 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
-[RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[FileName FileExt]);
-if strcmp(NomType,'*')% movies will be opened at the first frame
-    i1=1;
-    i2=[];
-    j1=[];
-    j2=[];
-end  
+% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
+[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
+% if strcmp(NomType,'*')% movies will be opened at the first frame
+%     i1=1;
+%     i2=[];
+%     j1=[];
+%     j2=[];
+% end  
 
 %% open the file or fill the GUI uvmat according to the detected file type
@@ -606,5 +607,5 @@
 %fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
-[tild,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
+[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
 % initiate the input file series and refresh the current field view: 
 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
@@ -1092,5 +1093,5 @@
 %fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
-[tild,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
+[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
 % initiate the input file series and refresh the current field view: 
 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2);
@@ -2446,5 +2447,5 @@
 for imap=1:numel(IndexObj)
     iobj=IndexObj(imap);
-    [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj})% project field on the object
+    [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
 
     if ~isempty(errormsg)
