Index: /trunk/src/civ.m
===================================================================
--- /trunk/src/civ.m	(revision 440)
+++ /trunk/src/civ.m	(revision 441)
@@ -415,7 +415,7 @@
 set(handles.RootFile,'String',RootFile)
 if strcmp(ExtInput,'.nc')
-    SubDirCiv=SubDir;
-else
-    SubDirCiv=[SubDir '.civ'];
+    SubDirCiv=regexprep(SubDir,[SuddirImages '^'],'');%suppress the root  SuddirImages;
+else
+    SubDirCiv= '.civ';
 end
 set(handles.SubdirCiv1,'String',SubDirCiv)
@@ -442,11 +442,15 @@
 %% look for an image documentation file
 ext_imadoc='';%default
+SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
+filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
+if ~exist(filexml,'file')
+    filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
+end
 RootName=fullfile(RootPath,RootFile);
-if exist([RootName '.xml'],'file')
+if exist(filexml,'file')
     ext_imadoc='.xml';
-elseif exist([RootName '.civxml'],'file')
-    ext_imadoc='.civxml';
-elseif exist([RootName '.civ'],'file')
+elseif exist(fullfile(RootPath,SubDir,[RootFile '.civ']),'file')
     ext_imadoc='.civ';
+    fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']);
 elseif exist([RootName '.avi'],'file')
     ext_imadoc='.avi';
@@ -465,12 +469,6 @@
     drawnow
     switch ext_imadoc
-        case '.civxml'%OBSOLETE
-            [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
-                nom_type_ima='_i_j';
-            end
         case '.xml'
-            [XmlData,warntext]=imadoc2struct([RootName '.xml']);
+            [XmlData,warntext]=imadoc2struct(filexml);
             ext_ima_read=[];
             nom_type_read=[];
@@ -508,6 +506,6 @@
             end
         case '.civ'% OBSOLETE: case of .civ image documentation file
-            [error,time,TimeUnit,mode,npx,npy]=read_imatext([RootName '.civ']);
-            if error==2, msgbox_uvmat('WARNING',['no file ' RootName '.civ']);
+            [error,time,TimeUnit,mode,npx,npy]=read_imatext(fileciv);
+            if error==2, msgbox_uvmat('WARNING',['no file ' fileciv]);
             elseif error==1, msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
             end
@@ -522,5 +520,5 @@
                 hhh=which('videoreader');
                 if isempty(hhh)%use old video function of matlab
-                    imainfo=aviinfo([RootName ext_imadoc]);%read infos on the avi movie
+                    imainfo=aviinfo([RootName ext_imadoc]);%read infos on the avi movie TO REPLACE mmreader
                     dt=1/imainfo.FramesPerSecond;%time interval between successive frames
                     MaxIndex_i=imainfo.NumFrames;%number of frames
@@ -681,5 +679,5 @@
 if get(handles.CheckCiv1,'Value')% if Civ1 is performed
     set(handles.SubdirCiv2,'String',SubDir);% set by default civ2 directory the same as civ1 
-    set(handles.ListSubdirCiv2,'Value',ilist)
+%     set(handles.ListSubdirCiv2,'Value',ilist)
 else % if Civ1 data already exist
     errormsg=find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory
@@ -1903,8 +1901,12 @@
 end
 %check result directory
-subdir_civ1=get(handles.SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf output data
-subdir_civ2=get(handles.SubdirCiv2,'String');
-if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir
+subdir_civ1=regexprep(get(handles.SubdirCiv1,'String'),'^.','');%subdirectory subdir_civ1 for the netcdf output data
+subdir_civ2=regexprep(get(handles.SubdirCiv2,'String'),'^.','');
+if isequal(subdir_civ1,''),subdir_civ1='civ'; end% put default subdir
+% subdir_civ1=[ '.' subdir_civ1];
+% subdir_civ2=[ '.' subdir_civ2];
 if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
+subdir_civ1=[SubdirImages '.' subdir_civ1];
+subdir_civ2=[SubdirImages '.' subdir_civ2];
 
 %% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV
@@ -2098,12 +2100,18 @@
                 detect=exist(filename,'file')==2;
                 if detect% if a netcdf file already exists
-                    indstr=regexp(subdir_civ1_new,'\D');
-                    if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number
-                        vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1;
-                        subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)];
-                    else
-                        vers=vers+1;
-                        subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)];       
+                    r=regexp(subdir_civ1_new,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number
+                    if isempty(r)
+                        r(1).root=[subdir_civ1_new '_'];
+                        r(1).num1='0';
                     end
+                    subdir_civ1_new=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1
+%                     indstr=regexp(subdir_civ1_new,'\D');
+%                     if indstr(end)<length(subdir_civ1_new) %subdir_civ1 ends by a number
+%                         vers=str2double(subdir_civ1_new(indstr(end)+1:end))+1;
+%                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) num2str(vers)];
+%                     else
+%                         vers=vers+1;
+%                         subdir_civ1_new=[subdir_civ1_new(1:indstr(end)) '_' num2str(vers)];       
+%                     end
                     subdir_civ2=subdir_civ1_new;
                     break
@@ -2467,6 +2475,6 @@
     end
 end
-set(handles.SubdirCiv1,'String',subdir_civ1);%update the edit box
-set(handles.SubdirCiv2,'String',subdir_civ2);%update the edit box
+set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubdirImages],''));%suppress the root  SuddirImages;);%update the edit box
+set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubdirImages],''));%update the edit box
 
 % For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED 
@@ -3563,41 +3571,41 @@
 end
 
-%------------------------------------------------------------------------
-% --- Executes on button press in ListSubdirCiv1.
-function ListSubdirCiv1_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-list_subdir_civ1=get(handles.ListSubdirCiv1,'String');
-val=get(handles.ListSubdirCiv1,'Value');
-SubDir=list_subdir_civ1{val};
-if strcmp(SubDir,'new...')
-    if get(handles.CheckCiv1,'Value')
-        SubDir='CIV'; %default subdirectory
-    else
-        msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation')
-        return
-    end    
-end
-set(handles.SubdirCiv1,'String',SubDir);
-errormsg=find_netcpair_civ(handles,1);
-if ~isempty(errormsg)
-    msgbox_uvmat('ERROR',errormsg)
-end
-    
-%------------------------------------------------------------------------
-% --- Executes on button press in ListSubdirCiv2.
-function ListSubdirCiv2_Callback(hObject, eventdata, handles)
-%------------------------------------------------------------------------
-list_subdir_civ2=get(handles.ListSubdirCiv2,'String');
-val=get(handles.ListSubdirCiv2,'Value');
-SubDir=list_subdir_civ2{val};
-if strcmp(SubDir,'new...')
-    if get(handles.CheckCiv2,'Value')
-        SubDir='CIV'; %default subdirectory
-    else
-        msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation')
-        return
-    end
-end
-set(handles.SubdirCiv2,'String',SubDir);
+% %------------------------------------------------------------------------
+% % --- Executes on button press in ListSubdirCiv1.
+% function ListSubdirCiv1_Callback(hObject, eventdata, handles)
+% %------------------------------------------------------------------------
+% list_subdir_civ1=get(handles.ListSubdirCiv1,'String');
+% val=get(handles.ListSubdirCiv1,'Value');
+% SubDir=list_subdir_civ1{val};
+% if strcmp(SubDir,'new...')
+%     if get(handles.CheckCiv1,'Value')
+%         SubDir='CIV'; %default subdirectory
+%     else
+%         msgbox_uvmat('ERROR','select CheckCiv1 to perform a new Civ operation')
+%         return
+%     end    
+% end
+% set(handles.SubdirCiv1,'String',SubDir);
+% errormsg=find_netcpair_civ(handles,1);
+% if ~isempty(errormsg)
+%     msgbox_uvmat('ERROR',errormsg)
+% end
+%     
+%------------------------------------------------------------------------
+% % --- Executes on button press in ListSubdirCiv2.
+% function ListSubdirCiv2_Callback(hObject, eventdata, handles)
+% %------------------------------------------------------------------------
+% list_subdir_civ2=get(handles.ListSubdirCiv2,'String');
+% val=get(handles.ListSubdirCiv2,'Value');
+% SubDir=list_subdir_civ2{val};
+% if strcmp(SubDir,'new...')
+%     if get(handles.CheckCiv2,'Value')
+%         SubDir='CIV'; %default subdirectory
+%     else
+%         msgbox_uvmat('ERROR','select CheckCiv2 to perform a new Civ operation')
+%         return
+%     end
+% end
+% set(handles.SubdirCiv2,'String',SubDir);
 
 %------------------------------------------------------------------------
Index: /trunk/src/find_file_series.m
===================================================================
--- /trunk/src/find_file_series.m	(revision 440)
+++ /trunk/src/find_file_series.m	(revision 441)
@@ -89,5 +89,5 @@
             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,SubDir,[RootFileNew '.xml']),'file') %|| (checkpair && exist(fullfile(fileparts(RootPath),[RootFileNew '.xml']),'file'))
                 RootFile=RootFileNew;
                 NomTypePref=r.tiretnum;
Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 440)
+++ /trunk/src/mouse_motion.m	(revision 441)
@@ -218,10 +218,10 @@
                         par.ImageWidth=size(par.ImageA,2);
                         Param.Civ1=par;
-                        ibx2=floor((par.Bx-1)/2);
-                        iby2=floor((par.By-1)/2);
-                        isx2=floor((par.Searchx-1)/2);
-                        isy2=floor((par.Searchy-1)/2);
-                        shiftx=par.Shiftx;
-                        shifty=par.Shifty;     
+                        ibx2=floor((par.CorrBoxSize(1)-1)/2);
+                        iby2=floor((par.CorrBoxSize(2)-1)/2);
+                        isx2=floor((par.SearchBoxSize(1)-1)/2);
+                        isy2=floor((par.SearchBoxSize(2)-1)/2);
+                        shiftx=par.SearchBoxShift(1);
+                        shifty=par.SearchBoxShift(2);     
                         hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
                         hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
Index: unk/src/name_generator.m
===================================================================
--- /trunk/src/name_generator.m	(revision 440)
+++ 	(revision )
@@ -1,283 +1,0 @@
-%'name_generator': creates a file name from a root name and indices. 
-%------------------------------------------------------------------------
-% [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);
-%------------------------------------------------------------------------           
-% This function detects the existence the constructed file name and it can
-% find indices according to file existence if they are not specified
-% rmq: this function is related to the reverse functions display2name and name2diplay 
-%------------------------------------------------------------------------
-% OUTPUT:
-% filename: string representing the file name (including path)
-% 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)
-%------------------------------------------------------------------------
-% INPUT:
-% 'filebase': the root name, 
-% 'num_i1: first labelling index i 
-% 'num_j1', first labelling index j
-% 'ext': file name extension (e.g. '.png' or '.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='_1-2': from pairs from a single index (e.g. 'aa_45-47.nc')
-%   nom_type='_1_1-2': pairs of j indices (e.g. 'aa_45_2-3.nc')
-%   nom_type='_1-2_1': 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, 
-%       comp_input=0: the index pair is automatically searched, choosing the most recent  file in case of multiple choice
-% 'num_i2': second index i (for nom_type involving index pairs (e.g. netc))
-% 'num_j2': second index j (for nom_type involving index pairs (e.g. netc))
-% 'subdir': (used for nom_type=netc...) string representing the name of the subdirectory 'subdir' containing file. 
-%       subdir='': no subdirectory, 
-%       subdir='?', the file is first searched with no subdirectory, then in the most recently modified subdirectory if not detected.
-
-% 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)
-sizf=size(filebase);
-if (~ischar(filebase)||~isequal(sizf(1),1)),filebase='';end
-if ~exist('ext','var')
-    ext='';
-end
-if ~exist('nom_type','var')
-    nom_type='';
-end
-if ~ischar(ext),ext='';end
-% idetect=0;
-if ~exist('num_i1','var') || isempty(num_i1) || isnan(num_i1)
-    num_i1=1; %default
-end
-if ~exist('num_j1','var') ||  isempty(num_j1) || isnan(num_j1)
-    num_j1=1; %default
-end
-if ~exist('num_i2','var') ||  isempty(num_i2) || isnan(num_i2)
-    num_i2=num_i1; %default
-end
-if ~exist('num_j2','var') || isempty(num_j2) || isnan(num_j2)
-    num_j2=num_j1; %default
-end
-if ~exist('subdir','var')|| isempty(subdir) 
-    subdir='' ; %default
-end
-num_i1_out=num_i1;%default output
-num_j1_out=num_j1;%default output
-num_i2_out=num_i2;%default output
-num_j2_out=num_j2;%default output
-test_pairs=numel(nom_type)>=2 &&(strcmp(nom_type,'_1-2_1-2')|| strcmp(nom_type(end-1:end),'ab')|| strcmp(nom_type(end-1:end),'AB')||...
-                strcmp(nom_type,'_1_1-2')|| strcmp(nom_type,'_1-2_1')||strcmp(nom_type,'_1-2'));
-%test_2D= strcmp(nom_type(end-1:end),'ab')|| strcmp(nom_type(end-1:end),'AB') ||strcmp(nom_type,'_1_1-2');
-%test_3D=strcmp(nom_type,'_1-2_1')|| strcmp(nom_type,'_1-2');
-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);
-    nom_type_mod=nom_type;
-    num_j_str='';
-    if strcmp(nom_type,'1')
-        filename=[filename num2str(num_i1) ext];
-    elseif length(nom_type)<=1%fixed name , no indexing, for instance '*'
-        filename=[filename ext];
-    else
-        nom_type_mod=nom_type;
-        if strcmp(nom_type(1),'_')
-            filename=[filename '_'];
-            nom_type_mod(1)=[];
-        end
-        if strcmp(nom_type_mod(end),'a')
-            nom_type_mod(end)=[];
-            num_j_str=char(num_j1+96);% lower letter corresponding to the index
-        elseif strcmp(nom_type_mod(end),'A')
-            nom_type(end)=[];
-            num_j_str=char(num_j1+64);% lower letter corresponding to the index
-        elseif isequal(numel(regexp(nom_type_mod,'_')),1)%if a second separator '_' exists in nom_type
-            num_j_str=['_' num2str(num_j1)];
-            nom_type_mod(regexp(nom_type_mod,'_'):end)=[];
-        else
-            num_j1_out=[];%no index j
-        end
-        if ~isnan(str2double(nom_type_mod))    
-            numtype=['%0' num2str(length(nom_type_mod)) '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 
-            filename=[filename ext];
-        end
-    end
-
-%case of derived file indexing (e.g. netcdf files)
-else
-    % case of an imposed image pair (comp_input=1)
-    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,'1_1-2')
-                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
-                    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,'1-2_1')
-                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                      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,'1-2')
-                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                     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,'1-2_1-2')
-                if isequal(num2str(num_i1),num2str(num_i2))% case of displacements at the same time
-                    app1= num2str(num_i1);
-                else
-                    app1= [num2str(num_i1) '-' num2str(num_i2)];
-                end
-                if isequal(num2str(num_j1),num2str(num_j2))% case of displacements at the same time
-                    app2= num2str(num_j1);
-                else
-                    app2= [num2str(num_j1) '-' num2str(num_j2)];
-                end     
-                filename=[filename app1 '_' app2 ext];
-            end
-            idetect=1;
-           % idetect=(exist(filename,'file')==2);
-     % 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(filename,num_i1,num_j1,num_i2,nom_type);
-    end
-    
-     %look for sub-directories containing netcdf files
-    if idetect==0 && isequal(subdir,'?')
-        [pathfile,name]=fileparts(filebase);
-        direct=dir(pathfile);%directory containing filebase
-        datedir=[];%default
-%         idir=0;
-        indir=find(cell2mat({direct.isdir}));% find indices of subdirectories
-        direct=direct(indir(3:end));% keep only the subdirectories,eliminating the two first terms '.' and '..'
-        lengthdir=length(direct);
-        if lengthdir==0
-            subdir='';% no subdirectory found
-        else
-            for idir=1:lengthdir
-                date_str=direct(idir).date;%string of the date of last modification
-                datedir(idir)=0;%default
-                char_code=double(date_str);% code of the date characters
-                special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
-                if isempty(find(special_char,1))% standard Ascii character 
-                    datedir(idir)=datenum(date_str);
-                end                            
-%                 datedir(idir)=datenum(direct(idir).date); %absolute date of last directory modification
-            end
-            [mostrec,indrec]=max(datedir);% most recently modified subdir chosen by default
-            subdir=direct(indrec).name; %chosen directory
-        end
-        filebasesub=fullfile(pathfile,subdir,name);
-        %if the image pair is imposed
-        if (exist('comp_input','var') && isequal(comp_input,1)) 
-            if isequal(nom_type,'#_ab')
-                filename=[filebasesub num2str(num_i1,'%03d') '_' num2stra(num_j1,nom_type) num2stra(num_j2,nom_type) ext];
-            elseif isequal(nom_type,'_1_1-2')
-                filename=[filebasesub '_' num2str(num_i1) '_' num2str(num_j1) '-' num2str(num_i2) ext];
-            elseif isequal(nom_type,'_1-2_1')
-                filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) '_' num2str(num_j1) ext];
-            elseif isequal(nom_type,'_1-2')
-                filename=[filebasesub '_' num2str(num_i1) '-' num2str(num_i2) ext];
-            end
-%             idetect=(exist(filename,'file')==2);
-        else
-            [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type);             
-        end
-    end
-end
-if ~strcmp(subdir,'?')
-    subdir_out=subdir;
-else
-    subdir_out='';
-end
-
-%------------------------------------------------------------------------
-% --- search the appropriate image pair (netcdf file) corresponding to a given image number
-function [filename,num_i1,num_j1,num_i2,num_j2,idetect]=search_pair(filebasesub,num_i1,num_j1,num_i2,nom_type)
-%------------------------------------------------------------------------
-% for nom_type=netc_2D or netc_old, it searches all the pairs corresponding
-% to num_i1, and chooses the most recent file.
-%for nom_type=netc_3D or netc_series, it searches all the pairs (num_i1
-%num_i2), with num_i1 as the first  index, and chooses the most recent file.
-
-filename=[];num_j2=[];idetect=0;%default values
-if isequal(nom_type,'#_ab')
-    dirpair=dir([filebasesub num2str(num_i1,'%03d') '_*.nc']);
-elseif isequal(nom_type,'_1_1-2')
-    dirpair=dir([filebasesub '_' num2str(num_i1) '_*-*.nc']);
-elseif isequal(nom_type,'_1-2_1')
-    dirpair=dir([filebasesub '_' num2str(num_i1) '-*_' num2str(num_j1) '.nc']);
-elseif isequal(nom_type,'_1-2')
-    dirpair=dir([filebasesub '_' num2str(num_i1) '-*.nc']);
-    if isempty(dirpair)
-        dirpair=dir([filebasesub '_*-' num2str(num_i2) '.nc']);
-    end
-end
-nbpair=length(dirpair);
-if nbpair >= 1 %choose the most recent file if several are found
-    idetect=1; %detected pair
-    datepair=zeros(1,nbpair);%default
-    for ipair=1:nbpair
-         date_str=dirpair(ipair).date;%string of the date of last modification
-         char_code=double(date_str);% code of the date characters
-         special_char=(char_code>127); %non standard Ascii character (e.g. date in french)
-         if isempty(find(special_char))% standard Ascii character 
-             datepair(ipair)=datenum(date_str);
-         end    
-    end
-    [choice,indpair]=max(datepair);
-    [pathname,file,field_count,str2,str_a,str_b]=name2display(dirpair(indpair).name);
-    num_i1=str2double(field_count);
-    num_i2=str2double(str2);
-    if isnan(num_i2)
-        num_i2=num_i1;
-    end
-    num_j1=stra2num(str_a);
-    num_j2=stra2num(str_b);
-     pathname=fileparts(filebasesub);% CORRIGE LE 6 JUIN (ETAIT DESACTIVE)
-    filename=fullfile(pathname,dirpair(indpair).name);
-end
-
-
Index: /trunk/src/read_field.m
===================================================================
--- /trunk/src/read_field.m	(revision 440)
+++ /trunk/src/read_field.m	(revision 441)
@@ -20,6 +20,6 @@
 %     = image : usual image as recognised by Matlab
 %     = multimage: image series stored in a single file
-%     = movie: movie read with mmreader
-%     = avi: avi movie read with aviread (OBSOLETE, used only when mmreader is not available, old versions of Matlab)
+%     = mmreader: movie read with mmreader
+%     = video: movie read with VideoReader (recent versions of Matlab)
 %     = vol: images representing scanned volume (images concatened in the y direction)
 % ParamIn: Matlab structure of input parameters
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 440)
+++ /trunk/src/series.m	(revision 441)
@@ -693,4 +693,6 @@
 
 %% update pair menus
+set(handles.Pairs,'Visible','on')
+set(handles.PairString,'Visible','on')
 ListView=get(handles.ListView,'String');
 ListView{iview}=num2str(iview);
@@ -698,4 +700,5 @@
 set(handles.ListView,'Value',iview)
 update_mode(handles,i1_series,i2_series,j1_series,j2_series,time)
+
 
 %% display the set of existing files as an image
@@ -851,5 +854,4 @@
 
 %% store the series info in 'UserData'
-
 SeriesData.i1_series{iview}=i1_series;
 SeriesData.i2_series{iview}=i2_series;
@@ -860,5 +862,18 @@
 set(handles.series,'UserData',SeriesData)
 
-
+%% check for pair display
+check_pairs=0;
+for iview=1:numel(SeriesData.i2_series)
+    if ~isempty(SeriesData.i2_series{iview})||~isempty(SeriesData.j2_series{iview})
+        check_pairs=1;
+    end
+end
+if check_pairs
+    set(handles.Pairs,'Visible','on')
+    set(handles.PairString,'Visible','on')
+else
+    set(handles.Pairs,'Visible','off')
+    set(handles.PairString,'Visible','off')
+end
 
 return
@@ -1041,6 +1056,10 @@
 %------------------------------------------------------------
 list_pair=get(handles.ListPairs,'String');%get the menu of image pairs
-string=list_pair{get(handles.ListPairs,'Value')};
-string=regexprep(string,',.*','');%removes time indication (after ',')
+if isempty(list_pair)
+    string='';
+else
+    string=list_pair{get(handles.ListPairs,'Value')};
+    string=regexprep(string,',.*','');%removes time indication (after ',')
+end
 PairString=get(handles.PairString,'Data');
 iview=get(handles.ListView,'Value');
@@ -1198,7 +1217,7 @@
 end
 set(handles.ListPairs,'String',displ_pair)
-if isempty(displ_pair)
-    msgbox_uvmat('ERROR',['no file available for the selected subdirectory ' SubDir])
-end
+% if isempty(displ_pair)
+%     msgbox_uvmat('ERROR',['no file available for the selected subdirectory' ])
+% end
 
 
@@ -1543,5 +1562,5 @@
 ref_j=ceil((first_j+last_j)/2);
 set(handles.num_ref_j,'String', num2str(ref_j))
-ref_j_Callback(hObject, eventdata, handles)
+num_ref_j_Callback(hObject, eventdata, handles)
 SeriesData=get(handles.series,'UserData');
 if ~isfield(SeriesData,'Time')
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 440)
+++ /trunk/src/uvmat.m	(revision 441)
@@ -909,6 +909,9 @@
 
 %% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
-filexml=[FileBase '.xml'];
-fileciv=[FileBase '.civ'];
+SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
+filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir
+if ~exist(filexml,'file')
+    filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy
+end
 warntext='';%default warning message
 NbSlice=1;%default
@@ -945,32 +948,35 @@
         end
     end  
-elseif exist(fileciv,'file')% if .civ file found 
-    [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
-    GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
-    GeometryCalib.Tx=0;
-    GeometryCalib.Ty=0;
-    GeometryCalib.Tz=1;
-    GeometryCalib.dpx=1;
-    GeometryCalib.dpy=1;
-    GeometryCalib.sx=1;
-    GeometryCalib.Cx=0;
-    GeometryCalib.Cy=0;
-    GeometryCalib.f=1;
-    GeometryCalib.kappa1=0;
-    GeometryCalib.CoordUnit='cm';
-    XmlData.GeometryCalib=GeometryCalib;
-    if error==2, warntext=['no file ' FileBase '.civ'];
-    elseif error==1, warntext='inconsistent number of fields in the .civ file';
-    end  
-    set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
-    set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
-    set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
-    set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
-    set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box 
-    set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box 
-    set(handles.view_xml,'Visible','on')   
-    set(handles.view_xml,'String','view .civ')
 else
-    set(handles.view_xml,'Visible','off')
+    fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']);
+    if exist(fileciv,'file')% if .civ file found (very old convention)
+        [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext(fileciv);
+        GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
+        GeometryCalib.Tx=0;
+        GeometryCalib.Ty=0;
+        GeometryCalib.Tz=1;
+        GeometryCalib.dpx=1;
+        GeometryCalib.dpy=1;
+        GeometryCalib.sx=1;
+        GeometryCalib.Cx=0;
+        GeometryCalib.Cy=0;
+        GeometryCalib.f=1;
+        GeometryCalib.kappa1=0;
+        GeometryCalib.CoordUnit='cm';
+        XmlData.GeometryCalib=GeometryCalib;
+        if error==2, warntext=['no file ' fileciv];
+        elseif error==1, warntext='inconsistent number of fields in the .civ file';
+        end
+        set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
+        set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
+        set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
+        set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
+        set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
+        set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
+        set(handles.view_xml,'Visible','on')
+        set(handles.view_xml,'String','view .civ')
+    else
+        set(handles.view_xml,'Visible','off')
+    end
 end
 
@@ -985,14 +991,11 @@
 end
 if ~isempty(XmlData.Time)
-%     nbfield=size(XmlData.Time,1);
-%     nbfield_j=size(XmlData.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(nbfield_j,1)% .Time is a line vector
+    if isequal(size(XmlData.Time,1),1)
+%     if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector
         NomType=get(handles.NomType,'String');
-        if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
+%         if isempty(nbfield_j)
+%         if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
             XmlData.Time=(XmlData.Time)';
-%             nbfield=nbfield_j;
-%             nbfield_j=1;
-        end
     end
 end
