Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 121)
+++ /trunk/src/civ.m	(revision 122)
@@ -67,8 +67,7 @@
 ext=[];
 testall=0;
-browse=[];
 %default input parameters:
 num1=1; % set of field i numbers
-num2=2; % set of field i numbers
+num2=1; % set of field i numbers
 num_a=1; % set of field j numbers (fields a)
 num_b=1; % second set of field j numbers (fields b)
@@ -87,6 +86,9 @@
     ext=param.ImaExt;
 end
-if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||...
-        strcmp(lower(ext),'.avi'));%if an image file has been opened by uvmat
+browse.num_i1=num1;
+browse.num_i2=num2;
+browse.num_j1=num_a;
+browse.num_j2=num_b;
+if ~isempty(ext) && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat
     set(handles.ImaExt,'String',ext)
     if exist('nom_type_read','var')
@@ -102,6 +104,5 @@
 set(handles.ImaDoc,'String',ext)
 
-%read names of the .exe file to adjust the interface according to
-%available binaries
+%read names of the .exe file to adjust the interface according to available binaries
 path_uvmat=which('uvmat');% check the path detected for source file uvmat
 path_UVMAT=fileparts(path_uvmat); %path to UVMAT
@@ -315,9 +316,12 @@
     browse=get(handles.browse_root,'UserData');
 end
-if length(ext)>1 && (~isempty(imformats(ext(2:end)))||...
-        isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat
-    set(handles.ImaExt,'String',ext)
+browse.num_i1=num_i1;
+browse.num_i2=num_i2;
+browse.num_j1=num_j1;
+browse.num_j2=num_j2;
+if length(ext)>1 && (~isempty(imformats(ext(2:end)))||strcmpi(ext,'.avi'));%if an image file has been opened by uvmat
+%     set(handles.ImaExt,'String',ext)
     browse.nom_type_ima=nom_type;
-    browse.field_count=num_i1;
+    browse.ext_ima=ext;
 end
 set(handles.ImaDoc,'String',ext);
@@ -437,5 +441,6 @@
 %------------------------------------------------------------------------
 set(handles.compare,'Visible','on')
-ext_ima=get(handles.ImaExt,'String');
+%ext_ima=get(handles.ImaExt,'String');
+ext_ima='';%default
 nom_type_ima=[];%default
 field_count=1;%default
@@ -447,14 +452,15 @@
 pxcmy_search=[];%default
 filebase=get(handles.RootName,'String');
-
 ext=get(handles.ImaDoc,'String');
 browse=get(handles.browse_root,'UserData');%default
-if ~isempty(browse)
-    if isfield(browse,'nom_type_ima')
-        nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name
-    end
-    if isfield(browse,'field_count')
-        field_count=browse.field_count;% get an image index type already determined by an input file
-    end
+if isfield(browse,'nom_type_ima')
+    nom_type_ima=browse.nom_type_ima;% get an image nomenclature type already determined by an input image name
+    ext_ima=browse.ext_ima;
+end
+if isfield(browse,'nom_type_nc')
+    nom_type_nc=browse.nom_type_nc;% get an image nomenclature type already determined by an input image name
+end
+if isfield(browse,'num_i1')
+    field_count=browse.num_i1;% get an image index type already determined by an input file
 end
 
@@ -522,5 +528,5 @@
 testima_xml=0;
 if isequal(ext,'.civxml')%TO ABANDON
-    [nbfield,nburst,time]=read_civxml([filebase '.civxml']);
+    [nbfield,nbfield2,time]=read_civxml([filebase '.civxml']);
     mode='pair j1-j2';
     if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
@@ -541,11 +547,11 @@
         time=XmlData.Time;
         nbfield=size(time,1);
-        nburst=size(time,2);
+        nbfield2=size(time,2);
         %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
-        if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
+        if isequal(nbfield,1) && ~isequal(nbfield2,1)% .Time is a line vector
             if numel(nom_type_read)>=2 && (strcmp(nom_type_read,'_i')||strcmp(nom_type_read(1:2),'%0')||strcmp(nom_type_read(1:2),'_%'))
                 time=time';
-                nbfield=nburst;
-                nburst=1;
+                nbfield=nbfield2;
+                nbfield2=1;
             end
         end
@@ -572,14 +578,14 @@
     end
     if ~isempty(ext_ima_read) && ~isempty(nom_type_read)
-        if isempty(ext_ima)
-            ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously
-        else   %keep the image extension
-            if  ~strcmp(ext_ima_read,ext_ima)
-                msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])
-            end
-        end
+%         if isempty(ext_ima)
+%             ext_ima=ext_ima_read;% define image extension from the xml file if an image has not been opened previously
+%         else   %keep the image extension
+%             if  ~strcmp(ext_ima_read,ext_ima)
+%                 msgbox_uvmat('WARNING',['FirtsImage extension ' ext_ima_read ' announced in the xml file inconsistent with the selected image'])
+%             end
+%         end
         nom_type_ima=nom_type_read;
     end
-elseif isequal(ext,'.civ')% case of .civ image documentation file
+elseif strcmp(ext,'.civ')% case of .civ image documentation file
     [error,time,TimeUnit,mode,npx,npy]=read_imatext([filebase '.civ']);
     if error==2, msgbox_uvmat('WARNING',['no file ' filebase '.civ']);
@@ -588,5 +594,5 @@
     %         ImaExt='.png';
     nom_type_ima='png_old';
-elseif isequal(lower(ext),'.avi')
+elseif strcmpi(ext,'.avi')
     nom_type_ima='*';
     ext_ima=ext;
@@ -606,5 +612,6 @@
 set(handles.ImaDoc,'BackgroundColor',[1 1 1])
 
-%get the imabe nomenclature type if not defiend by the input file nor by the xml file
+%get the imabe nomenclature type if not defined by the input file nor by the xml file
+dirima=[];%default
 if isempty(nom_type_ima)
     %look for double image series '_i_j'
@@ -616,16 +623,39 @@
             % look for other images series
             dirima=dir([filebase '*' num2str(first_i) '.*']);
-            if ~isempty(dirima)
-                [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
-            end
-        else
-            [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
-        end
-    else
-        [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
-    end
-end
-% no image documentation file found: look for a series of existing images or .nc files
-if isempty(time) && ~isequal(ext,'.nc') && ~strcmp(nom_type_ima,'none') && ~strcmp(nom_type_ima,'') && ~strcmp(nom_type_ima,'*')
+            if isempty(dirima)
+                % look for other images series witth letter appendix
+                appendix=char(96+first_j);
+                dirima=dir([filebase '*' num2str(first_i) appendix '.*']);
+%                 if ~isempty(dirima)
+%                     [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+%                 end
+%             else
+%                 [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+            end
+%         else
+%             [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+        end
+%     else
+%         [pp,ff,fc,str2,str_a,str_b,ext_ima,nom_type_ima]=name2display(dirima(1).name);
+    end
+end
+for ilist=1:numel(dirima)
+    [pp,ff,fc,str2,str_a,str_b,ext_list,nom_type_list]=name2display(dirima(ilist).name);
+    form=imformats(ext_list(2:end));
+    if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
+        ext_ima=ext_list;
+        nom_type_ima=nom_type_list;
+            break
+    end
+end
+% no image documentation file found: look for a series of existing files,images by priority or .nc files
+if isempty(nom_type_ima)
+    ext_search=ext;
+    nom_type_search=nom_type_nc;
+else
+    ext_search=ext_ima;
+    nom_type_search=nom_type_ima;
+end
+if isempty(time) && ~strcmp(nom_type_search,'none') && ~strcmp(nom_type_search,'') && ~strcmp(nom_type_search,'*')
     subdir=get(handles.subdir_civ1,'String');
     incr_pair=[0 0];%default
@@ -634,8 +664,8 @@
     end
     %     nbdetect=0;%test of detected images
-    field_i=field_count;
+    field_i=browse.num_i2;
     idetect=1;
     while idetect==1 %look for the maximum file number in the series
-        imagename=name_generator(filebase,field_i+1,1,ext_ima,nom_type_ima);
+        imagename=name_generator(filebase,field_i+1,1,ext_search,nom_type_search);
         idetect=(exist(imagename,'file')==2);
         if idetect
@@ -645,9 +675,9 @@
         %             nbdetect=nbdetect+(exist(imagename,'file')==2);
     end
-    nb_field=field_i;% last detected field number
-    field_i=field_count;%look for the minimum file number in the series
+    nbfield=field_i;% last detected field number
+    field_i=browse.num_i1;%look for the minimum file number in the series
     idetect=1;
     while idetect==1
-        imagename=name_generator(filebase,field_i-1,1,ext_ima,nom_type_ima);
+        imagename=name_generator(filebase,field_i-1,1,ext_search,nom_type_search);
         idetect=(exist(imagename,'file')==2);
         if idetect
@@ -655,13 +685,11 @@
         end
     end
-    first_i=max(field_i,1);
-    
-     switch nom_type_ima
-        case {'_i_j','%01dA','%02dA','%03dA','%04dA'}
-        field_i=field_count;
-        field_j=1;
+    first_i=max(field_i,1); 
+    if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j
+        field_i=browse.num_i1;
+        field_j=browse.num_j2;
         jdetect=1;
         while jdetect==1 %look for the maximum file number in the series
-            imagename=name_generator(filebase,field_i,field_j,ext_ima,nom_type_ima);
+            imagename=name_generator(filebase,field_i,field_j,ext_search,nom_type_search);
             jdetect=(exist(imagename,'file')==2);
             if jdetect
@@ -671,30 +699,20 @@
             %             nbdetect=nbdetect+(exist(imagename,'file')==2);
         end
-        nb_field_j=field_j-1;% last detected field number
+        nbfield2=field_j;% last detected field number
      end
-
-    
-    
+ 
     %determine the set of times and possible intervals for CIV
     %   dt=(1/1000)*str2num(get(handles.dt,'String'));
-    time=(0:nb_field-1)';% time=file index -1  by default
-
-    switch nom_type_ima
-        case {'_i_j','%01dA','%02dA','%03dA','%04dA'}
+    time=(0:nbfield-1)';% time=file index -1  by default
+    if numel(regexp(nom_type_search,'\D'))>=1%two indices i and j
+%     switch nom_type_search  
+%         case {'_i_j','%01dA','%02dA','%03dA','%04dA'}
         % time=[0:nb_field-1]'*ones(1,nb_field_j);% time=file index -1  by default
-        [x,y]=meshgrid([0:2-1],[0:152-1]);
+        [x,y]=meshgrid(0:nbfield2-1,0:nbfield-1);
         time=x+y;
 %         time=[0:nb_field-1]'*[0:nb_field_j-1];% time=file index -1  by default
     end
-    
-    
-    set(handles.mode,'String',{'series(Di)'})
-end
-% if isequal(nom_type_ima,'none')% no file numbering used
-%   first_i=1;
-%   last_i=1;
-%    first_j=1;
-%   last_j=1;
-% end
+%     set(handles.mode,'String',{'series(Di)'})
+end
 
 if exist('time','var')
@@ -722,9 +740,7 @@
 
 %%%%%%%%%%%  set the menus of image pairs and default selection for civ   %%%%%%%%%%%%%%%%%%%
-if isequal(nom_type_ima,'_i')|| isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1))
+test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D'));%images with single indexing
+if test_ima_i || isequal(nom_type_nc,'_i1-i2')||~(exist('nbfield2','var')&&(nbfield2~=1))
     set(handles.mode,'String',{'series(Di)'})
-    set(handles.mode,'Value',1)
-elseif isequal(nom_type_ima,'png_old')||isequal(nom_type_nc,'netc_old')
-    set(handles.mode,'String',{'pair j1-j2'})
     set(handles.mode,'Value',1)
 elseif (nbfield==1)% simple series in j
@@ -733,15 +749,7 @@
 else
     set(handles.mode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice
-    if nbfield2 <= 5
+    if nbfield2 <= 10
         set(handles.mode,'Value',1)% advice 'pair j1-j2' for small burst
     end
-    %     else
-    %     if isequal(mode,'volume')
-    %         set(handles.mode,'Value',3)
-    %     elseif nbfield2 <= 5
-    %         set(handles.mode,'Value',1)% advice 'pair j1-j2' for small bursts
-    %     else
-    %         set(handles.mode,'Value',2)% advice series Dj for long bursts, not volume
-    %     end
 end
 
@@ -777,6 +785,6 @@
 set(handles.RUN, 'Enable','On')
 set(handles.RUN,'BackgroundColor',[1 0 0])
-  set(handles.BATCH,'Enable','On')
-    set(handles.BATCH,'BackgroundColor',[1 0 0])
+set(handles.BATCH,'Enable','On')
+set(handles.BATCH,'BackgroundColor',[1 0 0])
 
 %%%%% store the root input filename for future opening
@@ -2165,7 +2173,4 @@
     end
 end
-
-
-
 if batch
     if isfield(sparam,'BatchMode')
@@ -2184,30 +2189,5 @@
 set(handles.waitbar_civ2,'Position',[0.946 0.219 0.03 0.001])
 set(handles.waitbar_patch2,'Position',[0.946 0.0 0.03 0.001])
-
 drawnow
-%get the filename root, nomenclature and numbers
-
-% for Windows system find the UBC path name if needed
-% if ~isunix & isequal(todo_path(1:2),'\\') & isequal(filebase(2:3),':\')
-%     cur_dir=pwd;
-%     if ~isequal(cur_dir(2:3),':\')
-%         cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M:
-%     end
-%     [ss,ww]=dos(['net use ' filebase(1:2)]);
-%     if isequal(ss,0)
-%         rankpath=findstr(ww,'\\');
-%         if ~isempty(rankpath)
-%             wwrest=ww(rankpath:end);
-%             rankend=min(find(double(wwrest)==10))-1;
-%             filebase=[wwrest(1:rankend) filebase(3:end)];
-%             set(handles.RootName,'String',filebase);
-%         end
-%     else
-%          msgbox_uvmat('ERROR','for BATCH option, UBC file names, beginning by \\, are needed');
-% %          set(handles.BATCH, 'Enable','On')
-% %          set(handles.BATCH,'BackgroundColor',[1 0 0])
-%          return
-%     end
-% end
 
 % set the list of files and check them
@@ -2240,5 +2220,4 @@
         [s,w]=unix('ps faux |grep civ|wc -l');
         w(end)=[];
-        str2num(w)+numel(num1_civ1)
         if str2num(w)+numel(num1_civ1)> MaxCivProcesses
             msgbox_uvmat('ERROR',{['There are already ' w ' civ processes running locally'];'Use BATCH or submit RUN later'})
@@ -2247,5 +2226,4 @@
     end
 end
-
 display('files OK, processing...')
 nbfield=numel(num1_civ1);
@@ -2325,6 +2303,4 @@
     %%%%%%%%%%%%%%%%%%%
 end
-
-
 
 %get patch2 parameters
@@ -2812,7 +2788,9 @@
 ext_ima=get(handles.ImaExt,'String');
 nom_type_nc=browse.nom_type_nc;
-nom_type_ima2=browse.nom_type_ima;
-if isequal(nom_type_ima2,[]),nom_type_ima2='ima_num';end; %default
-if isequal(nom_type_nc,[]),nom_type_nc='_i1-i2';end; %default
+if isfield(browse,'nom_type_ima')
+    nom_type_ima2=browse.nom_type_ima;
+end
+if isempty(nom_type_ima2),nom_type_ima2='1';end; %default
+if isempty(nom_type_nc),nom_type_nc='_i1-i2';end; %default
 [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...
     find_pair_indices(handles,mode);
@@ -2950,5 +2928,5 @@
                 if ~exist(file_ref,'file')
                     msgbox_uvmat('ERROR',['reference file ' file_ref ' not found for fix2'])
-                    filecell=[];
+                    filecell={};
                     return
                 end
@@ -2967,5 +2945,5 @@
 if ~exist(Path_ima,'dir')
     msgbox_uvmat('ERROR',['path to images ' Path_ima ' not found'])
-    filecell=[];
+    filecell={};
     return
 end
@@ -2974,7 +2952,7 @@
 m2='';
 [erread,message]=fileattrib(Path_ima);
-if ~isempty(message) & ~isequal(message.UserWrite,1)
+if ~isempty(message) && ~isequal(message.UserWrite,1)
     msgbox_uvmat('ERROR',['No writting access to ' Path_ima])
-    filecell=[];
+    filecell={};
     cd(currentdir);
     return
@@ -2986,10 +2964,13 @@
     detect=1;
     while detect==1 %create a new subdir if the netcdf files already exist
-        for ifile=1:nbfield;
+        vers=0;
+        subdir_civ1_new=subdir_civ1;
+        for ifile=1:nbfield
             for j=1:nbslice
-                filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);
+                filename=name_generator(filebase_nc,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);
                 detect=exist(filename,'file')==2;
                 if detect% if a netcdf file already exists
-                    subdir_civ1=[subdir_civ1 '.0'];
+                    vers=vers+1;
+                    subdir_civ1_new=[subdir_civ1 '_' num2str(vers)];
                     subdir_civ2=subdir_civ1;
                     break
@@ -3001,19 +2982,25 @@
             end
         end
+        subdir_civ1=subdir_civ1_new;
         %create the new subdir_civ1
         if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
             [m1,m2,m3]=mkdir(subdir_civ1);
             if ~isequal(m2,'')
-                msgbox_uvmat('ERROR', m2)
-                %msgbox(m2);%error message for directory creation
+                msgbox_uvmat('ERROR', m2)%error message for directory creation
+                cd(currentdir)
+                filecell={};
+                return
             end
         end
         if strcmp(compare,'stereo PIV')&&(strcmp(mode,'pair j1-j2')||strcmp(mode,'series(Dj)')||strcmp(mode,'series(Di)'))%check second nc series
+            vers=0;
+            subdir_civ1_new=subdir_civ1;
             for ifile=1:nbfield
                 for j=1:nbslice
-                    filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
+                    filename=name_generator(filebase_A,num1_civ1(ifile),num_a_civ1(j),'.nc',nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1_new);%
                     detect=exist(filename,'file')==2;
                     if detect% if a netcdf file already exists
-                        subdir_civ1=[subdir_civ1 '.0'];
+                        vers=vers+1;
+                        subdir_civ1_new=[subdir_civ1 '_' num2str(vers)];
                         subdir_civ2=subdir_civ1;
                         break
@@ -3025,4 +3012,5 @@
                 end
             end
+            subdir_civ1=subdir_civ1_new;
             %create the new subdir_civ1
             if ~exist(fullfile(Path_ima,subdir_civ1),'dir')
@@ -3030,4 +3018,7 @@
                 if ~isequal(m2,'')
                     msgbox_uvmat('ERROR', m2)
+                    cd(currentdir)
+                    filecell={};
+                    return
                 end
             end
@@ -3047,5 +3038,6 @@
         if idetectmin==0,
             msgbox_uvmat('ERROR',[filecell.ima1.civ1{ifile,indexj} ' not found'])
-            filecell=[];
+            filecell={};
+            cd(currentdir)
             return
         end
@@ -3053,5 +3045,5 @@
         if idetectmin==0,
             msgbox_uvmat('ERROR',[filecell.ima2.civ1{ifile,indexj} ' not found'])
-            filecell=[];
+            filecell={};
             cd(currentdir)
             return
@@ -3071,5 +3063,5 @@
             if idetectmin==0,
                 msgbox_uvmat('ERROR',[filecell.imaA1.civ1{ifile,indexj} ' not found'])
-                filecell=[];
+                filecell={};
                 cd(currentdir)
                 return
@@ -3078,5 +3070,5 @@
             if idetectmin==0,
                 msgbox_uvmat('ERROR',[filecell.imaA2.civ1{ifile,indexj} ' not found'])
-                filecell=[];
+                filecell={};
                 cd(currentdir)
                 return
@@ -3092,4 +3084,10 @@
                 nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
             detect=exist(filename,'file')==2;
+            if detect==0
+                msgbox_uvmat('ERROR',[filename ' not found'])
+                filecell={};
+                cd(currentdir)
+                return
+            end
             filecell.nc.civ1(ifile,j)={filename};
         end
@@ -3104,7 +3102,5 @@
                     set(handles.RUN, 'Enable','On')
                     set(handles.RUN,'BackgroundColor',[1 0 0])
-                    %                         set(handles.BATCH, 'Enable','On')
-                    %                         set(handles.BATCH,'BackgroundColor',[1 0 0])
-                    filecell=[];
+                    filecell={};
                     cd(currentdir)
                     return
@@ -3141,14 +3137,20 @@
             if ~isequal(m2,'')
                 msgbox_uvmat('ERROR', m2)
+                filecell={};
+                cd(currentdir)
+                return
             end
         end
         if strcmp(compare,'stereo PIV')%check second nc series
+            vers=0;
+            subdir_civ2_new=subdir_civ2;
             for ifile=1:nbfield
                 for j=1:nbslice
                     filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...
-                        nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2);%
+                        nom_type_nc,1,num2_civ2(ifile),num_b_civ1(j),subdir_civ2_new);%
                     detect=exist(filename,'file')==2;
                     if detect% if a netcdf file already exists
-                        subdir_civ2=[subdir_civ2 '.0'];
+                        vers=vers+1;
+                        subdir_civ2_new=[subdir_civ2 '_' num2str(vers)];
                         break
                     end
@@ -3159,10 +3161,13 @@
                 end
             end
+            subdir_civ2=subdir_civ2_new;
             %create the new subdir_civ1
             if ~exist(fullfile(Path_ima,subdir_civ2),'dir')
                 [m1,m2,m3]=mkdir(subdir_civ2);
                 if ~isequal(m2,'')
-                    msgbox_uvmat('ERROR', m2)
-                    %msgbox(m2);%error message for directory creation
+                    msgbox_uvmat('ERROR', m2)%error message for directory creation
+                    cd(currentdir)
+                    filecell={};
+                    return
                 end
             end
@@ -3171,5 +3176,4 @@
 end
 cd(currentdir);%come back to the current working directory
-
 
 %%%%%%%%%%%%%  if civ2 results are obtained or used  %%%%%%%%%%%%%
@@ -3184,5 +3188,5 @@
                 if ~exist(filename,'file')
                     msgbox_uvmat('ERROR',['input file ' filename ' not found'])
-                    filecell=[];
+                    filecell={};
                     return
                 end
@@ -3216,7 +3220,4 @@
                         set(handles.RUN, 'Enable','On')
                         set(handles.RUN,'BackgroundColor',[1 0 0])
-                        %                                set(handles.BATCH, 'Enable','On')
-                        %                     set(handles.BATCH,'BackgroundColor',[1 0 0])
-                        cd(currentdir)
                         return
                     end
@@ -4233,10 +4234,13 @@
 %------------------------------------------------------------------------
 % --- transform numbers to letters
-function str=num2stra(num,nom_type);
-%------------------------------------------------------------------------
-if isequal(nom_type,'png_old') | isequal(nom_type,'netc_old') |isequal(nom_type,'raw_SMD')
+function str=num2stra(num,nom_type)
+%------------------------------------------------------------------------
+if isempty(nom_type)
+    str='';
+elseif strcmp(nom_type(end),'a')
     str=char(96+num);
-elseif isequal(nom_type,'_i')|isequal(nom_type,'_i1-i2')...
-        |isequal(nom_type,'ima_num')| isequal(nom_type,'avi')| isequal(nom_type,'none')
+elseif strcmp(nom_type(end),'A')
+    str=char(96+num);
+elseif isempty(nom_type(2:end))%a single index
     str='';
 else
@@ -5065,5 +5069,5 @@
 fprintf(fid, ['PixCmXY ' par.pxcmx ' ' par.pxcmy '\n' ]);
 fprintf(fid, ['XX 1' '\n' ]);
-fprintf(fid, ['ShiftXY 0 0\n']);
+fprintf(fid, 'ShiftXY 0 0\n');
 fprintf(fid, ['Grid ' par.gridflag '\n' ]);
 fprintf(fid, ['GridName ' regexprep(par.gridname,'\\','\\\\') '\n']);
@@ -5246,5 +5250,5 @@
 fileinput=[PathName FileName];
 sizf=size(fileinput);
-if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
+if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
 [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
 ref.filebase=fullfile(Path,File);
Index: /trunk/src/name2display.m
===================================================================
--- /trunk/src/name2display.m	(revision 121)
+++ /trunk/src/name2display.m	(revision 122)
@@ -13,13 +13,13 @@
 %   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
 %   nom_type='*':constant name for a file representing a series (e.g. avi movie)
-%   nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
-%   nom_type='#', series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
-%   nom_type='_i_j': matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
-%   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc') 
+%   nom_type='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png').
+%   nom_type='_1','_01','_001'...':  series of files with a single index i with separator '_'(e.g. 'aa_045.png').
+%   nom_type='1a','1A','01a','01A',... with a numerical index and an index letter(e.g.'aa45b.png') (lower or upper case)
+%   nom_type='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index
+%   nom_type='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
+%   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
 %   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
 %   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
-%   nom_type='#a','#A", with a numerical index and an index letter(e.g.'aa045b.png') (lower or upper case)
-%   nom_type='raw_SMD', same as '#' but with no extension ext='', OBSOLETE
-%   nom_type='#_ab', from pairs of '#' images (e.g. 'aa045bc.nc'), ext='.nc', OBSOLETE (replaced by '_i_j1-j2')
+%   nom_type='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), ext='.nc'
 %subdir: name of the subdirectory for netcdf files
 %
@@ -44,7 +44,7 @@
 
         %recognize the name form
-filerawascii=double(RootFile);%ascci code
-val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
-indsel=find(val);% character indices of non numerical characters
+% filerawascii=double(RootFile);%ascci code
+% val=(48>filerawascii)|(filerawascii>57); % test for the non-numerical characters
+indsel=regexp(RootFile,'\D');% character indices of non numerical characters
 filelit=RootFile(indsel);% fileraw name with numbers removed
 nbchar=length(indsel);
@@ -69,50 +69,27 @@
 penult=double(RootFile(indcur-1));%ascii code of the penultimate character
 testsub=0; %default 
+% case of an indexed series in a single file
 if strcmpi(ext,'.avi')
      nom_type='*';
-      %case of old image nomenclature
-elseif (strcmp(ext,'.png') || strcmp(ext,'')) &&  penult >= 48 && penult <= 57 && (last < 48 || last > 57)
-    % if the penultimate character is a number and the last a letter
-    % search the appendix a,b,c,
-    str_a=last_str; %put appendix a,b,c....
-    indcur=indcur-1;
-    if strcmp(ext,'.png'), nom_type='#a'; end
-    if strcmp(ext,''), nom_type='raw_SMD'; end      
-    num=1;count=0; % extract the numerical appendix
-    while num==1;
-        filascii=double(RootFile(indcur));
-        if (48>filascii)||(filascii>57); % select the non-numerical characters
-            num=0; 
-        else
-            indcur=indcur-1; count=count+1;
-        end
+%case of a numerical index follewed by a lower case letter (e.g. a,b,c):
+%the penultimate character is a number and the last one a letter (lower case: last >= 97 && last <= 122
+%                                                                 capital letter:  last >= 65 && last <= 90)                                                             
+elseif  penult >= 48 && penult <= 57 && (last >= 65 && last <= 90)||(last >= 97 && last <= 122)
+    str_a=last_str; %extract appendix a,b,c... or A,B,C... as output.
+    ind_end=indcur-1; %current index just before the suffix letter
+    indices_root=regexp(RootFile(1:indcur-1),'\D');%detect non digit characters
+    indcur=max(indices_root);
+    field_count=RootFile(indcur+1:ind_end);
+    charstring=['%0' num2str(length(field_count)) 'd'];
+    nom_type=num2str(1,charstring);
+    if strcmp(RootFile(indcur),'_')
+       nom_type=['_' nom_type];
+       indcur=indcur-1;
     end
-    if count~=0             
-            field_count=RootFile(indcur+1:indcur+count);% set the selected field number
-    end
-elseif  penult >= 48 && penult <= 57  && (last <= 66 && last >= 65)% PCO camera Toulouse, end with A or B (NEW)
-    % if the penultimate character is a number and the last a letter
-    % search the appendix a,b,c,
-    str_a=last_str; %put appendix a,b,c....
-    indcur=indcur-1;
-    num=1;count=0; % extract the numerical appendix
-    while num==1;
-        filascii=double(RootFile(indcur));
-        if (48>filascii)||(filascii>57); % select the non-numerical characters
-            num=0; 
-        else
-            indcur=indcur-1; count=count+1;
-        end
-    end
-    if strcmp('0',RootFile(indcur+1)); % select the non-numerical characters
-        nom_type=['%0' num2str(length(RootFile(indcur+1:end-1))) 'dA'];
+    if (last >= 65 && last <= 90)
+        nom_type=[nom_type 'A'];
     else
-        nom_type='#A';
-    end  
-   
-    if count~=0             
-            field_count=RootFile(indcur+1:indcur+count);% set the selected field number
+        nom_type=[nom_type 'a'];
     end   
-%     indcur=indcur-1;
 elseif strcmp(filelit(end-2:end),'-_-_')%new  nomenclature appendix num1-num2_num_a-num_b
     field_count=num0;
@@ -149,5 +126,5 @@
     str2='';
     str_a=num3;
-    nom_type='_i_j';
+    nom_type='_1_1';
 elseif strcmp(filelit(end),'_')
     indcur=separ3-1;
@@ -157,23 +134,31 @@
     %detect zeros before the number
 %     count=0; % extract the numerical appendix
-    if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters
-        nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd'];
-    else
-        nom_type='_i';
-    end  
-    field_count=RootFile(separ3+1:end);% set the selected field number'%03d' 
+    field_count=RootFile(separ3+1:end);% set the selected field number'%03d'
+    charstring=['%0' num2str(length(field_count)) 'd'];
+    nom_type=['_' num2str(1,charstring)];
+%     if strcmp('0',RootFile(separ3+1)); % select the non-numerical characters
+%         nom_type=['_%0' num2str(length(RootFile(separ3+1:end))) 'd'];
+%     else
+%         nom_type='_i';
+%     end  
+     
 elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d
     last=RootFile(indcur-1:indcur);
-    if isequal(length(last),2) && double(last(1)) >= 97 && double(last(1)) <= 122 ...% = 1 for letters
-            && double(last(2)) >= 97 && double(last(2)) <= 122
+    if isequal(length(last),2) 
           str_a=last(1);%put appendix a,b,c, ou d
           str_b=last(2);%put appendix a,b,c, ou d
 %           indcur=indcur-3;
           separ0=indsel(end-3);
-        num0=RootFile(separ0+1:separ1-1);
-        field_count=num0;
+        field_count=RootFile(separ0+1:separ1-1);
         indcur=separ0;
-        nom_type='#_ab';
-        testsub=1;
+        if double(last) >= 97 & double(last)<= 122 
+            nom_type='_ab';
+            testsub=1;
+        elseif double(last) >= 65 & double(last) <= 90 
+            nom_type='_AB';
+            testsub=1;
+        end
+        charstring=['%0' num2str(length(field_count)) 'd'];
+        nom_type=[num2str(1,charstring) nom_type];
     end
 %search for other names with counter
@@ -191,10 +176,12 @@
             if count~=0   
                 field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d'
-                if isequal(field_count(1),'0')
-                    nbfigures=length(field_count);
-                    nom_type=['%0' num2str(nbfigures) 'd'];
-                else
-                    nom_type='#';
-                end
+                charstring=['%0' num2str(length(field_count)) 'd'];
+                nom_type=num2str(1,charstring);
+%                 if isequal(field_count(1),'0')
+%                     nbfigures=length(field_count);
+%                     nom_type=['%0' num2str(nbfigures) 'd'];
+%                 else
+%                     nom_type='#';
+%                 end
             end
     end
Index: /trunk/src/name_generator.m
===================================================================
--- /trunk/src/name_generator.m	(revision 121)
+++ /trunk/src/name_generator.m	(revision 122)
@@ -1,5 +1,5 @@
 %'name_generator': creates a file name from a root name and indices. 
 %------------------------------------------------------------------------
-% [filename,idetect,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
+% [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
 %        name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
 %------------------------------------------------------------------------           
@@ -10,5 +10,4 @@
 % OUTPUT:
 % filename: string representing the file name (including path)
-% idetect: =1 if the file is detected, 0 otherwise
 % num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out: index numbers and subdirectory detected 
 %            for free input (= to the corresponding input indices when comp_input=1)
@@ -19,19 +18,16 @@
 % 'num_j1', first labelling index j
 % 'ext': file name extension (e.g. '.png' or '.nc')
-% 'nom_type': string defining the kind of nomenclature used:
-%       nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
-%       nom_type='*': the same  file [filebase ext] contains successive fields (ex avi movies)
-%       nom_type='%03d' or '%04d', series of indexed images with numbers completed with zeros to 3 or 4 digits, e.g.'aa045.tif'
-%       nom_type='_i': series of files with a single index i preceded by '_'(e.g. 'aa_45.png').
-%       nom_type='_%03d', '_%04d', or '_%05d', series of indexed images with _ and numbers completed with zeros to 3, 4 or 5 digits, e.g.'aa_045.tif'
-%       nom_type='#' series of indexed images wich is not series_i [filebase index ext], e.g. 'aa045.jpg' or 'aa45.tif'
-%       nom_type='_i_j' matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
-%       nom_type='_i1-i2' from pairs from a single index (e.g. 'aa_45-47.nc') 
-%       nom_type='_i_j1-j2'pairs of j indices (e.g. 'aa_45_2-3.nc')
-%       nom_type='_i1-i2_j' pairs of i indices (e.g. 'aa_45-46_2.nc')
-%       nom_type='%3da','%3dA' with a numerical index and an index letter(e.g.'aa045b.png'), 
-%       nom_type='#a','#A' with a numerical index and an index letter(e.g.'aa045b.png'), OBSOLETE (replaced by 'series_i_j')
-%       nom_type='#_ab' from pairs of '#a' images (e.g. 'aa045bc.nc'),
-%       nom_type='%3d_ab' from pairs of '%3da' images (e.g. 'aa045bc.nc')
+%nom_type: char chain characterizing the file nomenclature: with values
+%   nom_type='': constant name [filebase ext] (default output if 'nom_type' is undefined)
+%   nom_type='*':constant name for a file representing a series (e.g. avi movie)
+%   nom_type='1','01',or '001'...': series of files with a single index i without separator(e.g. 'aa045.png').
+%   nom_type='_1','_01','_001'...':  series of files with a single index i with separator '_'(e.g. 'aa_045.png').
+%   nom_type='1a','1A','01a','01A',... with a numerical index and an index letter(e.g.'aa45b.png') (lower or upper case)
+%   nom_type='_1a','_1A','_01a','_01A',...: idem, with a separator '_' before the index
+%   nom_type='_1_1','_01_1',...: matrix of files with two indices i and j separated by '_'(e.g. 'aa_45_2.png')
+%   nom_type='_i1-i2': from pairs from a single index (e.g. 'aa_45-47.nc')
+%   nom_type='_i_j1-j2': pairs of j indices (e.g. 'aa_45_2-3.nc')
+%   nom_type='_i1-i2_j': pairs of i indices (e.g. 'aa_45-46_2.nc')
+%   nom_type='_1_ab','1_ab','01_ab'..., from pairs of '#' images (e.g.'aa045bc.nc'), ext='.nc'
 %'comp_input' (for nom_type involving index pairs (e.g. netc))
 %       comp_input=1: the index pair is imposed, 
@@ -45,5 +41,5 @@
 % A FAIRE: si comp_inpu=0, si _i_j n'existe pas, chercher _i, 
 function [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,subdir_out]=...
-           name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir);
+           name_generator(filebase,num_i1,num_j1,ext,nom_type,comp_input,num_i2,num_j2,subdir)
 sizf=size(filebase);
 if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end
@@ -75,58 +71,81 @@
 num_i2_out=num_i2;%default output
 num_j2_out=num_j2;%default output
-
-test_pairs=strcmp(nom_type,'netc_old')| strcmp(nom_type,'netc_2D') | strcmp(nom_type,'netc_3D')| strcmp(nom_type,'_i1-i2_j1-j2')| ...
-  strcmp(nom_type,'netc_series')| strcmp(nom_type,'#_ab')| strcmp(nom_type,'_i_j1-j2')| strcmp(nom_type,'_i1-i2_j')| strcmp(nom_type,'_i1-i2');
-test_2D= strcmp(nom_type,'netc_old') |strcmp(nom_type,'netc_2D')|strcmp(nom_type,'#_ab') |strcmp(nom_type,'_i_j1-j2');
-test_3D=strcmp(nom_type,'netc_3D') |strcmp(nom_type,'netc_series')| strcmp(nom_type,'_i1-i2_j')| strcmp(nom_type,'_i1-i2');
-if strcmp(nom_type,'series_i')| strcmp(nom_type,'_i');
-        filename=[filebase '_' num2str(num_i1) ext];
-        num_i2_out=num_i1;
-        num_j1_out=[];
-        num_j2_out=[]; 
-elseif length(nom_type)==5 && strcmp(nom_type(1:3),'_%0')&& strcmp(nom_type(5),'d');
-        filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext];
-        num_i2_out=num_i1;
-        num_j2_out=num_j1;
-elseif strcmp(nom_type,'series_i_j')| strcmp(nom_type,'_i_j')
-        filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext];
-        num_i2_out=num_i1;
-        num_j2_out=num_j1;
-elseif strcmp(nom_type,'png_old')| strcmp(nom_type,'#a')| strcmp(nom_type,'#A')
-        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext];
-        num_i2_out=num_i1;
-        num_j2_out=num_j1;
-elseif  length(nom_type)>=5 & strcmp(nom_type(2:3),'%0') & strcmp(nom_type(5),'d')  %strcmp(nom_type,'_%04dA') %camera PCO Toulouse
-        filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext];
-        num_i2_out=num_i1;
-        num_j2_out=num_j1;   
-elseif strcmp(nom_type,'raw_SMD') %suffix a, b, c without extension
-        filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type)];
-        num_i2_out=num_i1;
-        num_j2_out=num_j1;
-elseif strcmp(nom_type,'ima_num')| strcmp(nom_type,'#')
-        filename=[filebase num2str(num_i1) ext];
-        num_i2_out=num_i1;
-        num_j1_out=[];
-        num_j2_out=[];
-elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end),'d')
-        filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before
-        num_i2_out=num_i1;
-        num_j1_out=[];
-        num_j2_out=[];
-elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end-1:end),'dA')
-        filename=[filebase num2str(num_i1,nom_type(1:end-1)) num2stra(num_j1,'#A') ext]; %test number with a 0 before
-        num_i2_out=num_i1;
-        num_j1_out=[];
-        num_j2_out=[];
-
+test_pairs=numel(nom_type)>=2 &&(strcmp(nom_type,'_i1-i2_j1-j2')|| strcmp(nom_type(end-1:end),'ab')|| strcmp(nom_type(end-1:end),'AB')||...
+                strcmp(nom_type,'_i_j1-j2')|| strcmp(nom_type,'_i1-i2_j')||strcmp(nom_type,'_i1-i2'));
+%test_2D= strcmp(nom_type(end-1:end),'ab')|| strcmp(nom_type(end-1:end),'AB') ||strcmp(nom_type,'_i_j1-j2');
+%test_3D=strcmp(nom_type,'_i1-i2_j')|| strcmp(nom_type,'_i1-i2');
+if ~isequal(subdir,'') && ~isequal(subdir,'?') 
+      [Path,Name]=fileparts(filebase);
+      filename=fullfile(Path,subdir,Name);
+else
+    filename=filebase;%default
+end 
+if ~test_pairs%case of a single index i, and possibly j
+    numlength=numel(nom_type);
+    num_j_str='';
+    if strcmp(nom_type(1),'_')
+        filename=[filename '_'];
+        nom_type(1)=[];
+    end
+    if strcmp(nom_type(end),'a')
+        nom_type(end)=[];
+        num_j_str=char(num_j1+96);% lower letter corresponding to the index
+    elseif strcmp(nom_type(end),'A')
+        nom_type(end)=[];
+        num_j_str=char(num_j1+64);% lower letter corresponding to the index
+    elseif isequal(numel(regexp(nom_type(2:end),'_')),1)%if a separator '_' exists in nom_type
+        num_j_str=['_' num2str(num_j1)];
+        nom_type(regexp(nom_type(2:end),'_'):end)=[];
+    else
+        num_j1_out=[];%no index j
+    end
+    if ~isempty(str2num(nom_type))    
+        numtype=['%0' num2str(length(nom_type)) 'd'];%indicate the number of digits (0 before the number)
+        filename=[filename num2str(num_i1,numtype) num_j_str ext];
+        num_i2_out=num_i1_out;
+        num_j2_out=num_j1_out;
+    else %fixed name , no indexing, for instance '*'
+%           filebasesub=filebase;
+        filename=[filename ext];
+    end
+%     if  strcmp(nom_type,'_i');
+%         filename=[filebase '_' num2str(num_i1) ext];
+%         num_i2_out=num_i1;
+%         num_j1_out=[];
+%         num_j2_out=[];
+%     elseif length(nom_type)==5 && strcmp(nom_type(1:3),'_%0')&& strcmp(nom_type(5),'d');
+%         filename=[filebase '_' num2str(num_i1,nom_type(2:5)) ext];
+%         num_i2_out=num_i1;
+%         num_j2_out=num_j1;
+%     elseif  strcmp(nom_type,'_i_j')
+%         filename=[filebase '_' num2str(num_i1) '_' num2str(num_j1) ext];
+%         num_i2_out=num_i1;
+%         num_j2_out=num_j1;
+%     elseif  strcmp(nom_type,'#a')| strcmp(nom_type,'#A')
+%         filename=[filebase num2str(num_i1,'%03d') num2stra(num_j1,nom_type) ext];
+%         num_i2_out=num_i1;
+%         num_j2_out=num_j1;
+%     elseif  length(nom_type)>=5 & strcmp(nom_type(2:3),'%0') & strcmp(nom_type(5),'d')  %strcmp(nom_type,'_%04dA') %camera PCO Toulouse
+%         filename=[filebase nom_type(1) num2str(num_i1,nom_type(2:4)) num2stra(num_j1,nom_type) ext];
+%         num_i2_out=num_i1;
+%         num_j2_out=num_j1;
+%     elseif  strcmp(nom_type,'#')
+%         filename=[filebase num2str(num_i1) ext];
+%         num_i2_out=num_i1;
+%         num_j1_out=[];
+%         num_j2_out=[];
+%     elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end),'d')
+%         filename=[filebase num2str(num_i1,nom_type) ext]; %test number with a 0 before
+%         num_i2_out=num_i1;
+%         num_j1_out=[];
+%         num_j2_out=[];
+%     elseif length(nom_type)>=4 & strcmp(nom_type(1:2),'%0') & strcmp(nom_type(end-1:end),'dA')
+%         filename=[filebase num2str(num_i1,nom_type(1:end-1)) num2stra(num_j1,'#A') ext]; %test number with a 0 before
+%         num_i2_out=num_i1;
+%         num_j1_out=[];
+%         num_j2_out=[];
+%     end
 %case of derived file indexing (e.g. netcdf files)
-elseif test_pairs
-    filebasesub=filebase;
-    % get the root name filebasesub for the netcdf files
-    if  ~strcmp(subdir,'') && ~strcmp(subdir,'?') 
-            [Path,Name]=fileparts(filebase);
-            filebasesub=fullfile(Path,subdir,Name);
-    end
+else
      %inexistant pair if num_i2=0 or num_j2=0
 %     if strcmp(num_i2,0)
@@ -139,34 +158,50 @@
 %     end
     % case of an imposed image pair (comp_input=1)
-    if  (exist('comp_input','var') & isequal(comp_input,1)) 
-            if isequal(nom_type,'netc_old')|isequal(nom_type,'#_ab')
+    if  (exist('comp_input','var') && isequal(comp_input,1))
+            if strcmp(nom_type(1),'_')
+                filename=[filename '_'];
+                nom_type(1)=[];
+            end
+            if strcmp(nom_type(end-1:end),'AB')||strcmp(nom_type(end-1:end),'ab')
+                if strcmp(nom_type(end-1:end),'AB')
+                    nchar=64;
+                else
+                    nchar=96;
+                end
+                if isequal(num_j1,num_j2)% case of displacements at the same time
+                    num_j_str=char(num_j1+nchar);
+                else
+                    num_j_str=[char(num_j1+nchar) char(num_j2+nchar)];
+                end
+                if strcmp(nom_type(end-2),'_')
+                    numstr=['%0' num2str(numel(nom_type)-3) 'd'];
+                    num_j_str=['_' num_j_str];
+                else
+                    numstr=['%0' num2str(numel(nom_type)-2) 'd'];
+                end
+                filename=[filename num2str(num_i1,numstr) num_j_str ext];
+                num_i2_out=num_i1;
+            elseif isequal(nom_type,'i_j1-j2')
                 if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
-                    filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) ext];
-                else
-                    filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) num2stra(num_j2,nom_type) ext];
+                    filename=[filename num2str(num_i1) '_' num2str(num_j1) ext];
+                else
+                    filename=[filename num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_j2) ext];
                 end
                 num_i2_out=num_i1;
-            elseif isequal(nom_type,'netc_2D')|isequal(nom_type,'_i_j1-j2')
-                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
-                    filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext];
-                else
-                    filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_j2) ext];
-                end
-                num_i2_out=num_i1;
-            elseif isequal(nom_type,'netc_3D') || isequal(nom_type,'_i1-i2_j')
+            elseif  isequal(nom_type,'i1-i2_j')
                 if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                      filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) ext];
-                else
-                    filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];
+                      filename=[filename num2str(num_i1) '_' num2str(num_j1) ext];
+                else
+                    filename=[filename num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];
                 end
                 num_j2_out=num_j1;
-            elseif isequal(nom_type,'netc_series') || isequal(nom_type,'_i1-i2')
+            elseif  isequal(nom_type,'i1-i2')
                 if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                     filename=[filebasesub '_' num2str(num_i1) ext];
-                else
-                    filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) ext];
+                     filename=[filename num2str(num_i1) ext];
+                else
+                    filename=[filename num2str(num_i1) '-' num2str(num_i2) ext];
                 end
                 num_j2_out=num_j1;
-            elseif isequal(nom_type,'_i1-i2_j1-j2')
+            elseif isequal(nom_type,'i1-i2_j1-j2')
                 if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
                     app1= [num2str(num_i1)];
@@ -179,5 +214,5 @@
                     app2= [num2str(num_j1) '-' num2str(num_j2)];
                 end     
-                filename=[filebasesub '_' app1 '_' app2 ext];
+                filename=[filename app1 '_' app2 ext];
             end
             idetect=1;
@@ -185,5 +220,5 @@
      % case of an image pair to determine (comp_input=0)
     else
-            [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type);
+          [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out,idetect]=search_pair(filename,num_i1,num_j1,num_i2,nom_type);
     end
     
@@ -230,13 +265,4 @@
         end
     end
-% elseif isequal(nom_type,'none')|isequal(nom_type,'')|isequal(nom_type,'*')
-else
-    filebasesub=filebase;
-    if ~isequal(subdir,'') && ~isequal(subdir,'?') 
-            [Path,Name]=fileparts(filebase);
-            filebasesub=fullfile(Path,subdir,Name);
-    end
-    filename=[filebasesub ext];
-    idetect=(exist(filename,'file')==2);  
 end
 if ~isequal(subdir,'?'), subdir_out=subdir; else, subdir_out='';end;
Index: /trunk/src/num2stra.m
===================================================================
--- /trunk/src/num2stra.m	(revision 121)
+++ /trunk/src/num2stra.m	(revision 122)
@@ -12,5 +12,5 @@
 % see also: stra2num, name_generator, name2display
 
-function str=num2stra(num,nom_type,index);
+function str=num2stra(num,nom_type,index)
 if ~exist('index','var')
     index=2; %index 1 or 2 of the file indices
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 121)
+++ /trunk/src/uvmat.m	(revision 122)
@@ -823,11 +823,11 @@
         set(handles.transform_fct,'Value',1); %  no transform by default
     else
-        if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) |...
+        if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
             (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
             set(handles.pxcm,'String','var')
             set(handles.pycm,'String','var')
         elseif isfield(GeometryCalib,'fx_fy')
-            pixcmx=GeometryCalib.fx_fy(1)%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
-            pixcmy=GeometryCalib.fx_fy(2)%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
+            pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
+            pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
             set(handles.pxcm,'String',num2str(pixcmx))
             set(handles.pycm,'String',num2str(pixcmy))
@@ -911,14 +911,17 @@
 state_j='off'; %default
 scan_option='i';%default
-switch NomType
-    case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices
+NomTypeRaw=regexprep(NomType(2:end), '-', '');
+if numel(regexp(NomTypeRaw,'\D'))>=1 
+%     case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices
         state_j='on';
         if isequal(nbfield,1)
-            scan_option='j';                 
+            scan_option='j'; %scan j index by default if nbfield=1                
         end 
 end
 if ~isempty(NomType_1)
-    switch NomType_1
-        case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
+    NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
+    if numel(regexp(NomTypeRaw,'\D'))>=1
+%     switch NomType_1
+%         case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
             state_j='on';
             if isequal(nbfield,1)
@@ -1486,5 +1489,5 @@
         ind_mask=findstr('mask',Name);
         i=ind_mask-1;
-        while val(i)==0 & i>0
+        while val(i)==0 && i>0
             i=i-1;
         end
@@ -1668,5 +1671,5 @@
 UvData=get(handles.uvmat,'UserData');
 
-while get(handles.speed,'Value')~=0 & isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
+while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
         errormsg=runpm(hObject,eventdata,handles,increment);
         if ~isempty(errormsg)
@@ -1902,5 +1905,5 @@
     FileType='vol';
 else 
-   form=imformats(Ext([2:end]));
+   form=imformats(Ext(2:end));
    if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
        if isequal(NomType,'*');
@@ -2059,5 +2062,5 @@
         FieldName='image';
     else 
-       form=imformats(Ext([2:end]));
+       form=imformats(Ext(2:end));
        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
            if isequal(NomType,'*');
@@ -2106,5 +2109,5 @@
         FieldName_1='image';
     else 
-       form=imformats(Ext_1([2:end]));
+       form=imformats(Ext_1(2:end));
        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
            if isequal(NomType_1,'*');
@@ -2623,5 +2626,5 @@
         %use of mask
         if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
-            if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
+            if isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
                  flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
                  AX=ObjectData.AX;
@@ -2629,16 +2632,16 @@
                  MaskX=ObjectData.MaskX;
                  MaskY=ObjectData.MaskY;
-                 if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
+                 if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
                      nxy=size(flag_mask);
                      sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
                      sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
-                     x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display 
-                     y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
+                     x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display 
+                     y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
                      %project on the positions of the scalar
                      npxy=size(ObjectData.A);
                      dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
                      dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
-                     xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
-                     yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];      
+                     xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
+                     yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);      
                      [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
                     flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
@@ -2650,5 +2653,5 @@
                  if isfield(ObjectData,'ListVarName')
                       for ilist=1:length(ObjectData.ListVarName)
-                           if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
+                           if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
                                ind_off=[ind_off ilist];
                            end
@@ -2841,5 +2844,5 @@
     Tabchar={''};%default
     Tabcell=[];
-    if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
+    if isfield(Field{2},'ListGlobalAttribute')&& ~isempty(Field{2}.ListGlobalAttribute)
         for iline=1:length(Field{2}.ListGlobalAttribute)
             Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
@@ -3801,5 +3804,5 @@
 index_code=get(handles.col_vec,'Value');% selected string index
 col_code= list_code{index_code(1)}; % selected field
-if isequal(col_code,'black') | isequal(col_code,'white')
+if isequal(col_code,'black') || isequal(col_code,'white')
    set(handles.slider1,'Visible','off')
    set(handles.slider2,'Visible','off')
@@ -4439,5 +4442,5 @@
 Data_uvmat=get(handles.uvmat,'UserData');
 evalin('base','global Data_uvmat')%make CurData global in the workspace
-display(['current field :'])
+display('current field :')
 evalin('base','Data_uvmat') %display CurData in the workspace
 commandwindow; %brings the Matlab command window to the front
@@ -4670,6 +4673,6 @@
         npx=size(UvData.Field.A,2);
         npy=size(UvData.Field.A,1);
-        xi=[0.5:npx-0.5];
-        yi=[0.5:npy-0.5];
+        xi=0.5:npx-0.5;
+        yi=0.5:npy-0.5;
         [Xi,Yi]=meshgrid(xi,yi);
         if isfield(UvData,'Object')
