Index: trunk/src/civ.m
===================================================================
--- trunk/src/civ.m	(revision 344)
+++ trunk/src/civ.m	(revision 353)
@@ -180,5 +180,5 @@
 end
 %[RootPath,RootFile,str1,str2,str_a,str_b,FileExt,NomType,subdir]=name2display(fileinput);
-[~,~,~,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput);
+[tild,tild,tild,i1,i2,j1,j2,FileExt,NomType]=fileparts_uvmat(fileinput);
 % filebase=fullfile(RootPath,RootFile);
 
@@ -351,11 +351,15 @@
 
 % form=imformats(ext_input(2:end));
+check_letter=0;
+check_separator=0;
 if ~isempty(ext_input)&&(~isempty(imformats(ext_input(2:end)))||strcmpi(ext_input,'.avi'))% if the extension corresponds to an image or movie format recognized by Matlab
     ext_ima=ext_input;
     nom_type_ima=nom_type_input;
     imagename=fileinput;
+    check_letter=~isempty(regexp(nom_type_ima,'[a|A]$'));%detect pair label by letter
 else %case of netcdf input file, look for corresponding images
     nom_type_nc=nom_type_input;
-    imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima);
+    imagename=fullfile_uvmat(RootPath,[],RootFile,ext_ima,nom_type_ima,1,[],1);
+    %imagename=name_generator(fullfile(RootPath,RootFile),1,1,ext_ima,nom_type_ima);
     i1_str='';
     j1_str='';
@@ -367,6 +371,6 @@
     %TODO: read the image name in the netcdf file (if documented)
     %look for double image series '_i_j'
-    check_letter=regexp(nom_type_nc,'[ab|AB]$');%detect pair label by letter
-    if ~isempty(check_letter)
+    check_letter=~isempty(regexp(nom_type_nc,'[ab|AB]$'));%detect pair label by letter
+    if check_letter
         j1_str=nom_type_nc(end-1);
         r=regexp(nom_type_nc,'_(?<num1>\d+)','names');
@@ -378,5 +382,5 @@
         r_end=regexp(NomTypeIma,'.\D(?<num2>\d+$','names');
         if ~isempty(r_end)
-            j1_str=r.num2
+            j1_str=r.num2;
         end
     end
@@ -401,5 +405,5 @@
     for ilist=1:numel(dirima)
         %[pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name);
-        [~,~,~,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name);
+        [tild,tild,tild,i1,i2,j1,j2,ext_list,nom_type_list]=fileparts_uvmat(dirima(ilist).name);
         form=imformats(ext_list(2:end));
         if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
@@ -432,5 +436,5 @@
     end
 end
-[RootPath,RootFile,i1_series,~,j1_series,~,NomType,FileType,Object]=find_file_series(imagename);
+[RootPath,RootFile,i1_series,tild,j1_series,tild,NomType,FileType,Object]=find_file_series(imagename);
 MaxIndex_i=max(i1_series(i1_series>0));
 MaxIndex_j=max(j1_series(j1_series>0));
@@ -464,5 +468,5 @@
     switch ext_imadoc
         case '.civxml'%OBSOLETE
-            [~,~,time]=read_civxml([RootName '.civxml']);
+            [tild,tild,time]=read_civxml([RootName '.civxml']);
             mode='pair j1-j2';
             if isempty(nom_type_ima)% dtermine types by default if not already selected by browser or uvmat
@@ -475,5 +479,5 @@
             if isfield(XmlData,'Heading')&&isfield(XmlData.Heading','ImageName')&&ischar(XmlData.Heading.ImageName)% get image nom type and extension from the xml file
                 %[PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
-                [~,~,~,~,~,~,~,~,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
+                [tild,tild,tild,tild,tild,tild,tild,tild,nom_type_read]=fileparts_uvmat(XmlData.Heading.ImageName);
                 fullname=fullfile(fileparts(RootName),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
                 if ~exist(fullname,'file')
@@ -590,9 +594,9 @@
 % test_ima_i=numel(nom_type_ima)>1 && isempty(regexp(nom_type_ima(2:end),'\D','once'))%=1 for images with single indexing
 % TODO: determine MaxIndex_i and MaxIndex_j using find_file_series (in the absence of xml file)
-try
-if (~check_letter&&~check_separator)|| isequal(nom_type_nc,'_1-2')|| (MaxIndex_j==1)
+% try
+if ~check_letter|| isequal(nom_type_nc,'_1-2')|| (MaxIndex_j==1)
     set(handles.ListPairMode,'Value',1)
     set(handles.ListPairMode,'String',{'series(Di)'})   
-elseif  MaxIndex_i==1 && MaxIndex_j% simple series in j
+elseif  MaxIndex_i==1 && MaxIndex_j>1% simple series in j
     set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'})
     if  MaxIndex_j <= 10
@@ -605,5 +609,5 @@
     end
 end
-end
+% end
 
 %% update the subdirectory display
@@ -1805,5 +1809,8 @@
     filebase_nc=filebase_B;
 end
-
+    [RootPath_ima1,RootFile_ima1]=fileparts(filebase_ima1);
+    [RootPath_ima2,RootFile_ima2]=fileparts(filebase_ima2);
+    [RootPath_nc,RootFile_ima1]=fileparts(filebase_nc);
+    
 %determine reference files for fix:
 file_ref_fix1={};%default
@@ -1824,5 +1831,5 @@
         if isequal(mode,'displacement')
             num_i1=num_i_ref;
-            num_i2=num_i_ref;
+ name_genna           num_i2=num_i_ref;
             num_j1=num_j_ref;
             num_j2=num_j_ref;
@@ -1852,5 +1859,7 @@
         for ifile=1:nbfield
             for j=1:nbslice
-                file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);%
+                [RootPath,RootFile]=fileparts(ref.filebase);
+                file_ref=fullfile_uvmat(RootPath,ref.subdir,RootFile,'.nc',ref.nom_type,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j));
+%                 file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);%
                 file_ref_fix1(ifile,j)={file_ref};
                 if ~exist(file_ref,'file')
@@ -1903,5 +1912,7 @@
         for ifile=1:nbfield
             for j=1:nbslice
-                file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);%
+                [RootPath,RootFile]=fileparts(ref.filebase);
+                file_ref=fullfile_uvmat(RootPath,ref.subdir,RootFile,'.nc',ref.nom_type,num_i1(ifile),num_i2(ifile),num_j1(j),num_j2(j));
+                %file_ref=name_generator(ref.filebase,num_i1(ifile),num_j1(j),'.nc',ref.nom_type,1,num_i2(ifile),num_j2(j),ref.subdir);%
                 file_ref_fix2(ifile,j)={file_ref};
                 if ~exist(file_ref,'file')
@@ -1944,4 +1955,5 @@
         for ifile=1:nbfield
             for j=1:nbslice
+                [RootPath,RootFile]=fileparts(ref.filebase_nc);
                 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;
@@ -2204,6 +2216,7 @@
         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=fullfile_uvmat(RootPath_nc,subdir_civ1,RootFile_nc,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
+                %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);%
                 filecell.nc.civ1(ifile,j)={filename};% name of the civ1 file
                 if ~exist(filename,'file')
@@ -2244,6 +2257,7 @@
             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_civ2(j),subdir_civ2);%
+                    filename=fullfile_uvmat(RootPath_A,subdir_civ2,RootFile_A,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
+%                     filename=name_generator(filebase_A,num1_civ2(ifile),num_a_civ2(j),'.nc',...
+%                         nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%
                     filecell.ncA.civ2(ifile,j)={filename};
                     if ~exist(filename,'file')
@@ -2262,6 +2276,7 @@
     for ifile=1:nbfield
         for j=1:nbslice
-            filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...
-                nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);
+            filename=fullfile_uvmat(RootPath_nc,subdir_civ2,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
+%             filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...
+%                 nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);
             detect=exist(filename,'file')==2;
             filecell.nc.civ2(ifile,j)={filename};
@@ -2274,5 +2289,6 @@
         for ifile=1:nbfield
             for j=1:nbslice
-                filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1);
+                filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,ext_ima,nom_type_ima1,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
+                %filename=name_generator(filebase_ima1, num1_civ2(ifile),num_a_civ2(j),ext_ima,nom_type_ima1);
                 idetect_2(j)=exist(filename,'file')==2;
                 filecell.ima1.civ2(ifile,j)={filename};%first image
@@ -2293,5 +2309,6 @@
         for ifile=1:nbfield
             for j=1:nbslice
-                filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2);
+                filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,ext_ima,nom_type_ima2,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
+               % filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),ext_ima,nom_type_ima2);
                 idetect_3(j)=exist(filename,'file')==2;
                 filecell.ima2.civ2(ifile,j)={filename};%first image
@@ -2312,6 +2329,7 @@
         for ifile=1:nbfield
             for j=1:nbslice
-                filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...
-                    nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%
+                 filename=fullfile_uvmat(RootPath_nc,subdir_civ2,RootFile_nc,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
+%                 filename=name_generator(filebase_nc,num1_civ2(ifile),num_a_civ2(j),'.nc',...
+%                     nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%
                 filecell.nc.civ2(ifile,j)={filename};
                 if ~exist(filename,'file')
@@ -2341,6 +2359,7 @@
         for ifile=1:nbfield
             for j=1:nbslice
-                filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',...
-                    nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
+                 filename=fullfile_uvmat(RootPath_AB,subdir_civ1,RootFile_AB,'.nc',nom_type_nc,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
+%                 filename=name_generator(filebase_AB,num1_civ1(ifile),num_a_civ1(j),'.nc',...
+%                     nom_type_nc,1,num2_civ1(ifile),num_b_civ1(j),subdir_civ1);%
                 filecell.st(ifile,j)={filename};
             end
@@ -2350,6 +2369,7 @@
         for ifile=1:nbfield
             for j=1:nbslice
-                filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',...
-                    nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%
+                 filename=fullfile_uvmat(RootPath_AB,subdir_civ2,RootFile_AB,'.nc',nom_type_nc,num1_civ2(ifile),num2_civ2(ifile),num_a_civ2(j),num_b_civ2(j));
+%                 filename=name_generator(filebase_AB,num1_civ2(ifile),num_a_civ2(j),'.nc',...
+%                     nom_type_nc,1,num2_civ2(ifile),num_b_civ2(j),subdir_civ2);%
                 filecell.st(ifile,j)={filename};
             end
@@ -2430,5 +2450,6 @@
             waitbar(ifile/nbfield);
             for j=1:nbslice
-                filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1);
+                 filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ1(ifile),num2_civ1(ifile),num_a_civ1(j),num_b_civ1(j));
+%                 filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1);
                 if ~exist(filename,'file')
                     A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1);
@@ -2436,5 +2457,6 @@
                 end
                 filecell.ima1.civ1(ifile,j)={filename};
-                filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2);
+                filename=fullfile_uvmat(RootPath_ima2,[],RootFile_ima2,'.png',nom_type_imanew2,num2_civ1(ifile),num2_civ1(ifile),num_b_civ1(j),num_b_civ1(j));
+                %filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2);
                 if ~exist(filename,'file')
                     A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2);
@@ -2451,5 +2473,6 @@
             waitbar(ifile/nbfield);
             for j=1:nbslice
-                filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1);
+                filename=fullfile_uvmat(RootPath_ima1,[],RootFile_ima1,'.png',nom_type_imanew1,num1_civ2(ifile),[],num_a_civ1(j));
+                %filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1);
                 if ~exist(filename,'file')
                     A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile));
@@ -2619,5 +2642,5 @@
 %     set(handles.RootName_1,'String',name);
     %[RootPath,RootFile,field_count,str2,str_a,str_b,xx,nom_type,SubDir]=name2display(name);
-    [~,~,RootFile,~,~,~,~,~,nom_type]=fileparts_uvmat(name);
+    [tild,tild,RootFile,tild,tild,tild,tild,tild,nom_type]=fileparts_uvmat(name);
     set(handles.RootName_1,'String',RootFile);
     browse=get(handles.RootName,'UserData');
@@ -2840,6 +2863,5 @@
 find_netcpair_civ1( handles)
 find_netcpair_civ2(handles)
-'TESTin'
-browse=get(handles.RootName,'UserData')
+browse=get(handles.RootName,'UserData');
 
 %------------------------------------------------------------------------
