Index: /trunk/src/dataview.m
===================================================================
--- /trunk/src/dataview.m	(revision 16)
+++ /trunk/src/dataview.m	(revision 17)
@@ -4,7 +4,7 @@
 % associated with the GUI dataview.fig
 %
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 %  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 %     This file is part of the toolbox UVMAT.
 % 
@@ -18,5 +18,5 @@
 %     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 %     GNU General Public License (file UVMAT/COPYING.txt) for more details.
-%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 
 function varargout = dataview(varargin)
@@ -43,8 +43,8 @@
 % End initialization code - DO NOT EDIT
 
-
+%------------------------------------------------------------------------
 % --- Executes just before dataview is made visible.
 function dataview_OpeningFcn(hObject, eventdata, handles, RootDir, SubCampaignTst,GeometryCalib)
-
+%------------------------------------------------------------------------
 % Choose default command line output for dataview
 handles.output = 'Cancel';
@@ -107,6 +107,4 @@
 end
 
-
-
 %------------------------------------------------------------------------
 % --- Outputs from this function are returned to the command line.
@@ -117,5 +115,4 @@
 delete(handles.figure)
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %------------------------------------------------------------------------
 % --- Executes on button press in browser.
@@ -136,5 +133,4 @@
 CampaignDir=uigetdir(CurrentFile,'Open the Campaign directory'); %file browser
 set(handles.RootDirectory,'String',CampaignDir)
-
 RootDirectory_Callback(hObject, eventdata, handles)
 
Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 16)
+++ /trunk/src/geometry_calib.m	(revision 17)
@@ -109,11 +109,8 @@
 %set(htable,'ColumnNames',{'x','y','z','X(pixels)','Y(pixels)'})
 
+%------------------------------------------------------------------------
 % --- Outputs from this function are returned to the command line.
 function varargout = geometry_calib_OutputFcn(hObject, eventdata, handles)
-% varargout  cell array for returning output args (see VARARGOUT);
-% hObject    handle to figure
-% eventdata  reserved - to be defined in a future version of MATLAB
-% handles    structure with handles and user data (see GUIDATA)
-
+%------------------------------------------------------------------------
 % Get default command line output from handles structure
 varargout{1} = handles.output;
@@ -123,11 +120,8 @@
 function Phi_Callback(hObject, eventdata, handles)
 
-
-
-
-%--------------------------------------------------
+%------------------------------------------------------------------------
 %read input xml file and update the edit boxes
 function loadfile(handles,fileinput)
-
+%------------------------------------------------------------------------
 %read the input xml file
 t=xmltree(fileinput);
@@ -267,5 +261,5 @@
 unit=unitlist{get(handles.CoordUnit,'value')};
 GeometryCalib.CoordUnit=unit;
-
+GeometryCalib.SourceCalib.PointCoord=Object.Coord;
 huvmat=findobj(allchild(0),'Name','uvmat');
 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat
@@ -285,48 +279,49 @@
     outputfile=answer{1};
 end
-testappend=0;
-if exist(outputfile,'file');%=1 if the output file already exists, 0 else 
-    t=xmltree(outputfile); %read the file
-    backupfile=outputfile;
-    testexist=2;
-    while testexist==2
-        backupfile=[backupfile '~'];% make a backup name by adding  ~ to the xml file name
-        testexist=exist(backupfile,'file');
-    end
-    [success,message]=copyfile(outputfile,backupfile);%make backup   
-    t=xmltree(outputfile); %read the file
-    uid=find(t,'ImaDoc');
-    if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
-        if isequal(success,1)
-            delete(outputfile)
-        else
-            msgbox_uvmat('ERROR',['error in the backup of the existing xml file: ' message])
-            return
-        end
-    else
-        uid_calib=find(t,'ImaDoc/GeometryCalib');
-        testappend=1;
-        if isempty(uid_calib)
-            [t,uid_calib]=add(t,1,'element','GeometryCalib');
-        else %if GeometryCalib already exists, delete its content
-            uid_child=children(t,uid_calib);
-            t=delete(t,uid_child);
-%             testappend=1;
-        end
-    end
-end
-if ~testappend %create a new xml file for calibration data
-    t=xmltree;
-    t=set(t,1,'name','ImaDoc');
-    [t,uid_calib]=add(t,1,'element','GeometryCalib');
-end
-% hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata
-% imagename=get(hgrid,'UserData');
-% if exist(imagename,'file')
-%     GeometryCalib.SourceCalib.ImageCalib=imagename;
+update_imadoc(GeometryCalib,outputfile)
+% testappend=0;
+% if exist(outputfile,'file');%=1 if the output file already exists, 0 else 
+%     t=xmltree(outputfile); %read the file
+%     backupfile=outputfile;
+%     testexist=2;
+%     while testexist==2
+%         backupfile=[backupfile '~'];% make a backup name by adding  ~ to the xml file name
+%         testexist=exist(backupfile,'file');
+%     end
+%     [success,message]=copyfile(outputfile,backupfile);%make backup   
+%     t=xmltree(outputfile); %read the file
+%     uid=find(t,'ImaDoc');
+%     if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup)
+%         if isequal(success,1)
+%             delete(outputfile)
+%         else
+%             msgbox_uvmat('ERROR',['error in the backup of the existing xml file: ' message])
+%             return
+%         end
+%     else
+%         uid_calib=find(t,'ImaDoc/GeometryCalib');
+%         testappend=1;
+%         if isempty(uid_calib)
+%             [t,uid_calib]=add(t,1,'element','GeometryCalib');
+%         else %if GeometryCalib already exists, delete its content
+%             uid_child=children(t,uid_calib);
+%             t=delete(t,uid_child);
+% %             testappend=1;
+%         end
+%     end
 % end
-GeometryCalib.SourceCalib.PointCoord=Object.Coord;
-t=struct2xml(GeometryCalib,t,uid_calib); 
-save(t,outputfile);
+% if ~testappend %create a new xml file for calibration data
+%     t=xmltree;
+%     t=set(t,1,'name','ImaDoc');
+%     [t,uid_calib]=add(t,1,'element','GeometryCalib');
+% end
+% % hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata
+% % imagename=get(hgrid,'UserData');
+% % if exist(imagename,'file')
+% %     GeometryCalib.SourceCalib.ImageCalib=imagename;
+% % end
+% GeometryCalib.SourceCalib.PointCoord=Object.Coord;
+% t=struct2xml(GeometryCalib,t,uid_calib); 
+% save(t,outputfile);
 msgbox_uvmat('CONFIRMATION',{[outputfile ' updated with calibration data'];...
     ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
@@ -364,13 +359,5 @@
 end
 % %record image source
-% hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata
-% imagename=get(hgrid,'UserData');
-% if exist(imagename,'file')
-%     GeometryCalib.SourceCalib.ImageCalib=imagename;
-% end
 GeometryCalib.SourceCalib.PointCoord=Object.Coord;
-
-
-%root PROJETS
 
 %open and read the dataview GUI
@@ -380,22 +367,4 @@
 end
 CalibData=get(handles.figure1,'UserData');%read the calibration image source on the interface userdata
-% filename='PROJETS';%default
-% if isfield(CalibData,'XmlInput')
-%      [pp,filename]=fileparts(CalibData.XmlInput);
-% end
-% while ~isequal(filename,'PROJETS') && numel(filename)>1
-%     filename_1=filename;
-%     pp_1=pp;
-%     [pp,filename]=fileparts(pp)
-% end
-% projinput=fullfile(pp_1,filename_1)
-% dd=dataview(projinput)
-
-% 
-% Device=[];%default
-% 
-% h_dataview=dataview;
-% hhdataview=guidata(h_dataview);
-% drawnow
 
 if isfield(CalibData,'XmlInput')
@@ -443,5 +412,5 @@
 end
 if testinput
-    outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib)%,SubCampaignTest)
+    outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib)
 end
 %     %A COMPLETER
@@ -955,5 +924,5 @@
     set(handles.ListCoord,'String',Tabchar)  
     ListCoord_Callback(hObject, eventdata, handles)
-    PLOT_Callback(hObject,eventdata,handles)
+    MenuPlot_Callback(hObject,eventdata,handles)
 end
 
@@ -1051,8 +1020,7 @@
 end
 
-
-
-% --------------------------------------------------------------------
+%------------------------------------------------------------------------
 function MenuCreateGrid_Callback(hObject, eventdata, handles)
+%------------------------------------------------------------------------
 hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
 CalibData=get(hcalib,'UserData');
@@ -1061,5 +1029,5 @@
     Tinput=CalibData.grid;
 end
-T=create_grid(Tinput);%display translate_points GUI and get shift parameters 
+T=create_grid(Tinput)%display the GUI create_grid 
 CalibData.grid=T;
 set(hcalib,'UserData',CalibData)
@@ -1067,22 +1035,30 @@
 %grid in phys space
 Coord_cell=get(handles.ListCoord,'String');
-data=read_geometry_calib(Coord_cell);
-data.Coord(:,1)=T(1)+data.Coord(:,1);
-data.Coord(:,2)=T(2)+data.Coord(:,2);
-data.Coord(:,3)=T(3)+data.Coord(:,3);
-data.Coord(:,[4 5])=data.Coord(:,[4 5]);
-for i=1:size(data.Coord,1)
-    for j=1:5
-          Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z
+data=read_geometry_calib(Coord_cell)
+nbpoints=size(data.Coord,1); %nbre of calibration points
+data.Coord(1:size(T,1),1:3)=T;
+for i=1:nbpoints
+   for j=1:5
+          Coord{i,j}=num2str(data.Coord(i,j),4);%display coordiantes with 4 digits
    end
 end
+for i=nbpoints+1:size(data.Coord,1)
+    for j=1:3
+          Coord{i,j}=num2str(data.Coord(i,j),4);%display coordiantes with 4 digits
+    end
+    for j=4:5
+          Coord{i,j}='';%display coordiantes with 4 digi
+    end
+end
+
+
+%size(data.Coord,1)
 Tabchar=cell2tab(Coord,'    |    ');
 set(handles.ListCoord,'Value',1)
 set(handles.ListCoord,'String',Tabchar)
 
-
-
-% --------------------------------------------------------------------
+%-----------------------------------------------------------------------
 function MenuTranslatePoints_Callback(hObject, eventdata, handles)
+%-----------------------------------------------------------------------
 hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib
 CalibData=get(hcalib,'UserData')
Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 16)
+++ /trunk/src/get_field.m	(revision 17)
@@ -1567,5 +1567,5 @@
 if ~isequal(path_get_field,PathName)
     CurrentPath=fileparts(which(ACTION));
-    if ~isequal(PathName,CurrentPath)
+    if ~isequal(CurrentPath,PathName)&&~isequal(CurrentPath,fullfile(PathName,'private'))
         addpath(PathName) 
         errormsg=check_functions;
Index: /trunk/src/private/ListDir.m
===================================================================
--- /trunk/src/private/ListDir.m	(revision 16)
+++ /trunk/src/private/ListDir.m	(revision 17)
@@ -1,4 +1,20 @@
 %'ListDir': scan the structure of the directory tree (for dataview.m)
 %------------------------------------------------------------------------
+% function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in)
+%
+% 
+% OUTPUT:
+% ListDevices: list of Devices 
+% ListRecords: list of records
+% ListXml: list of xml file names
+% List: structure representing the tree structure
+%
+%INPUT
+% CurrentPath: full name (including path) to the input campaign (or subcampaign), we assume that
+%          data are organised as (sub)campaign/Experiment/Device/(Record/)/file .xml
+% ListExperiments: list of experiments to scan (cell of names)
+% ListDevices_in: list of devices to scan (cell of names)
+% ListRecords_in: list of records to scan (cell of names)
+
 function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in)
 
@@ -73,6 +89,10 @@
 end
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% ListDevices: list of devices already scanned
+% ListDevices_in: list of input devices to scan
 function [testnew,testselect]=test_select(name,ListDevices,ListDevices_in)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 if ~isempty(ListDevices_in)
     testnew=0;
Index: /trunk/src/private/read_geometry_calib.m
===================================================================
--- /trunk/src/private/read_geometry_calib.m	(revision 16)
+++ /trunk/src/private/read_geometry_calib.m	(revision 17)
@@ -18,4 +18,5 @@
 nb_defining_points=length(Coord_cell);
 iline=0;
+data.Coord=[];%default
 for i=1:nb_defining_points
     coord_str=Coord_cell{i};%character string of line number i
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 16)
+++ /trunk/src/series.m	(revision 17)
@@ -1677,5 +1677,5 @@
 if ~isequal(path_series,PathName)
     CurrentPath=fileparts(which(ACTION));
-    if ~isequal(PathName,CurrentPath)
+    if ~isequal(CurrentPath,PathName)&&~isequal(CurrentPath,fullfile(PathName,'private'))
         addpath(PathName) 
         errormsg=check_functions;
@@ -4399,5 +4399,6 @@
             last_j2 =last_j +ind_shift(2);
             siz=size(SeriesData.Time{1});
-            if siz(1)>=last_i2 & siz(2)>=last_j2
+            if first_i1>=1 && first_j1
+                >=1 && siz(1)>=last_i2 && siz(2)>=last_j2
                 time_first=(time(first_i1,first_j1)+time(first_i2,first_j2))/2;
                 time_last=(time(last_i1,last_j1)+time(last_i2,last_j2))/2;
Index: /trunk/src/update_imadoc.m
===================================================================
--- /trunk/src/update_imadoc.m	(revision 16)
+++ /trunk/src/update_imadoc.m	(revision 17)
@@ -11,4 +11,11 @@
 if exist(outputfile,'file');%=1 if the output file already exists, 0 else  
     t=xmltree(outputfile); %read the file
+    backupfile=outputfile;
+    testexist=2;
+    while testexist==2
+       backupfile=[backupfile '~'];
+       testexist=exist(backupfile,'file');
+    end
+    [success,message]=copyfile(outputfile,backupfile);%make backup
     uid=find(t,'ImaDoc');
     if ~isequal(uid,1)
@@ -21,11 +28,11 @@
         [t,uid_calib]=add(t,1,'element','GeometryCalib');
     else %if GeometryCalib already exists, delete its content
-        backupfile=outputfile;
-        testexist=2;
-        while testexist==2
-           backupfile=[backupfile '~'];
-           testexist=exist(backupfile,'file');
-        end
-        [success,message]=copyfile(outputfile,backupfile);%make backup
+%         backupfile=outputfile;
+%         testexist=2;
+%         while testexist==2
+%            backupfile=[backupfile '~'];
+%            testexist=exist(backupfile,'file');
+%         end
+%         [success,message]=copyfile(outputfile,backupfile);%make backup
         if isequal(success,1)
             delete(outputfile)
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 16)
+++ /trunk/src/uvmat.m	(revision 17)
@@ -3995,5 +3995,5 @@
 PathName=list_path{ind_coord};
 CurrentPath=fileparts(which(coord_option));
-if ~isequal(PathName,CurrentPath)
+if ~isequal(PathName,CurrentPath)&&~isequal(CurrentPath,fullfile(PathName,'private'))
     addpath(PathName) 
     errormsg=check_functions;
