Index: /trunk/src/geometry_calib.m
===================================================================
--- /trunk/src/geometry_calib.m	(revision 1112)
+++ /trunk/src/geometry_calib.m	(revision 1113)
@@ -52,5 +52,5 @@
 % Edit the above text to modify the response to help geometry_calib
 
-% Last Modified by GUIDE v2.5 20-Sep-2018 19:04:30
+% Last Modified by GUIDE v2.5 05-Feb-2022 22:24:55
 
 % Begin initialization code - DO NOT edit
@@ -232,5 +232,5 @@
 
 %% Apply calibration
-[GeometryCalib,index,ind_removed,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration
+[GeometryCalib,index,ind_removed]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration
 if isempty(GeometryCalib)
     return
@@ -245,17 +245,13 @@
 GeometryCalib.SourceCalib.PointCoord=Coord;
 
-%% display calibration results on the GUI geometry_calib
-display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters
-display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters
-%     (rotation and translation of camera with  respect to the phys coordinates)
-
 %% set the default plane and display the calibration data errors for validation
 answer=msgbox_uvmat('INPUT_Y-N',{'store calibration data';...
     ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];...
     ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels'];
-    [num2str(numel(ind_removed)) ' points removed']});
-% SliceCoord_ref=[0 0 0]; %default reference plane
+    [num2str(numel(ind_removed)) ' points removed with ErrorMax > 3 rms']});
 checkslice=0;
 if strcmp(answer,'Yes') %store the calibration data
+    display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters on the GUI geometry_calib
+    display_extrinsic(GeometryCalib,handles)%display calibration extrinsic parameters on the GUI geometry_calib
     Z=Coord(:,3);
     if strcmp(calib_cell{val}(1:2),'3D') && isequal(max(Z),min(Z))%set the plane position for 3D (projection) calibration
@@ -348,10 +344,10 @@
         errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file
         if checkslice
-                    errormsg=update_imadoc(Slice,outputfile,'Slice');% introduce the slice position in the xml file
+            errormsg=update_imadoc(Slice,outputfile,'Slice');% introduce the slice position in the xml file
         end
         if ~strcmp(errormsg,'')
             msgbox_uvmat('ERROR',errormsg);
         end
-        
+
         %% display image with new calibration in the currently opened uvmat GUI
         FieldList=get(hhuvmat.FieldName,'String');
@@ -397,13 +393,13 @@
 %------------------------------------------------------------------------
 % --- activate calibration and store parameters in ouputfile .
-function [GeometryCalib,ind_max,ind_removed,Z_plane]=calibrate(Coord,CalibFcn,Intrinsic)
+function [GeometryCalib,ind_max,ind_removed]=calibrate(Coord,CalibFcn,Intrinsic)
 %------------------------------------------------------------------------
 
 index=[];
 GeometryCalib=[];
-ind_max=[];ind_removed=[];Z_plane=[];
+ind_max=[];ind_removed=[];
 % apply the calibration, whose type is selected in  handles.calib_type
 CoordFlip=Coord;
-CoordFlip(:,3)=-Coord(:,3);
+CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours
 if ~isempty(Coord)
     GeometryCalib=feval(CalibFcn,CoordFlip,Intrinsic);
@@ -414,13 +410,9 @@
     return
 end
-Z_plane=[];
 
 % estimate calibration error rms and max
-% X=Coord(:,1);
-% Y=Coord(:,2);
-Z=Coord(:,3);
 x_ima=Coord(:,4);
 y_ima=Coord(:,5);
-[Xpoints,Ypoints]=px_XYZ(GeometryCalib,[],Coord(:,1),Coord(:,2),Coord(:,3));% convention of downward z coordinate (facing the camera)
+[Xpoints,Ypoints]=px_XYZ(GeometryCalib,[],Coord(:,1),Coord(:,2),Coord(:,3));
 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));
 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));
@@ -430,14 +422,16 @@
 ind_max=index(ind_dim); % mark the index with maximum deviation
 
-% detect bad calibration points, marked by indices ind_bad, if the
+% detect bad calibration points, marked by indices ind_removed, if the
 % difference of actual image coordinates and those given by calibration is
-% greater than 2 pixels and greater than 4 rms.
+% greater than 2 pixels and greater than 3 rms.
 check_x=abs(Xpoints-x_ima)>max(2,3*GeometryCalib.ErrorRms(1));
 check_y=abs(Ypoints-y_ima)>max(2,3*GeometryCalib.ErrorRms(2));
-ind_removed=find(check_x | check_y)
+ind_removed=find(check_x | check_y);
 % repeat calibration without the excluded points:
 if ~isempty(ind_removed)
     Coord(ind_removed,:)=[];
-    GeometryCalib=feval(CalibFcn,Coord,Intrinsic);
+    CoordFlip=Coord;
+    CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours
+    GeometryCalib=feval(CalibFcn,CoordFlip,Intrinsic);
     X=Coord(:,1);
     Y=Coord(:,2);
@@ -450,10 +444,4 @@
 end
 GeometryCalib.ErrorMax=ErrorMax;
-% %set the Z position of the reference plane used for calibration
-% if isequal(max(Z),min(Z))%Z constant
-%     Z_plane=Z(1);
-%     GeometryCalib.NbSlice=1;
-%     GeometryCalib.SliceCoord=[0 0 Z_plane];
-% end
 
 
@@ -468,6 +456,4 @@
 [px]=polyfit(X,x_ima,1);
 [py]=polyfit(Y,y_ima,1);
-% T_x=px(2);
-% T_y=py(2);
 GeometryCalib.CalibrationType='rescale';
 GeometryCalib.fx_fy=[px(1) py(1)];%.fx_fy corresponds to pxcm along x and y
@@ -620,5 +606,5 @@
 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
 if exist('Rc_1','var')
-    GeometryCalib.CalibrationType='3D_linear';
+    GeometryCalib.CalibrationType='3D_extrinsic';
     GeometryCalib.fx_fy=fc';
     GeometryCalib.Cx_Cy=cc';
@@ -698,5 +684,5 @@
 
 if exist('Rc_1','var')
-    GeometryCalib.CalibrationType='3D_quadr';
+    GeometryCalib.CalibrationType='3D_extrinsic';
     GeometryCalib.fx_fy=fc';
     GeometryCalib.Cx_Cy=cc';
@@ -1163,13 +1149,15 @@
 
 % --------------------------------------------------------------------
-function MenuFlip_x_Callback(hObject, eventdata, handles)
+function MenuFlip_xy_Callback(hObject, eventdata, handles)
 Coord=get(handles.ListCoord,'Data');
 Coord(:,1)=-Coord(:,1);
+Coord(:,2)=-Coord(:,2);
 set(handles.ListCoord,'Data',Coord)
 
 % --------------------------------------------------------------------
-function MenuFlip_y_Callback(hObject, eventdata, handles)
+function MenuFlip_xz_Callback(hObject, eventdata, handles)
 Coord=get(handles.ListCoord,'Data');
-Coord(:,2)=-Coord(:,2);
+Coord(:,1)=-Coord(:,1);
+Coord(:,3)=-Coord(:,3);
 set(handles.ListCoord,'Data',Coord)
 
Index: /trunk/src/phys_XYZ.m
===================================================================
--- /trunk/src/phys_XYZ.m	(revision 1112)
+++ /trunk/src/phys_XYZ.m	(revision 1113)
@@ -79,7 +79,7 @@
 if isfield(Calib,'R')
     R=(Calib.R)';
-    R(3)=-R(3);
-    R(6)=-R(6);
-    R(9)=-R(9);
+%     R(3)=-R(3);
+%     R(6)=-R(6);
+%     R(9)=-R(9);
     c=Z0virt;
     cvirt=Z0virt;
Index: /trunk/src/px_XYZ.m
===================================================================
--- /trunk/src/px_XYZ.m	(revision 1112)
+++ /trunk/src/px_XYZ.m	(revision 1113)
@@ -57,5 +57,5 @@
     
     %camera coordinates
-    Zphys=-Zphys;%flip z coordinates
+    Zphys=Zphys;%flip z coordinates
     xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);
     yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 1112)
+++ /trunk/src/series.m	(revision 1113)
@@ -3143,9 +3143,9 @@
 if get(handles.CheckObject,'Value')
     SeriesData=get(handles.series,'UserData');
-    if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)
+    if isfield(SeriesData,'ProjObject') && ~isempty(SeriesData.ProjObject)% a projection object is already loaded in the GUI series
         set(handles.ViewObject,'Value',1)
         ViewObject_Callback(hObject, eventdata, handles)
     else
-        if ishandle(hset_object)
+        if ishandle(hset_object)% a projection object is already displayed in a GUI set_object
             uistack(hset_object,'top')% show the GUI set_object if opened
         else
@@ -3215,7 +3215,11 @@
     set(handles.ViewObject,'Value',0)
     UserData=get(handles.series,'UserData');
+    if isfield(UserData,'ProjObject')
     hset_object=set_object(UserData.ProjObject);
     set(hset_object,'Name','edit_object_series')
     set(get(hset_object,'Children'),'Enable','on')
+    else
+        msgbox_uvmat('ERROR','no projection object available');
+    end
 else
     hset_object=findobj(allchild(0),'Tag','set_object'); 
Index: /trunk/src/series/extract_rdvision.m
===================================================================
--- /trunk/src/series/extract_rdvision.m	(revision 1112)
+++ /trunk/src/series/extract_rdvision.m	(revision 1113)
@@ -206,9 +206,18 @@
                 logdir=[Param.OutputSubDir Param.OutputDirExt];
                 [success,errormsg] = copyfile(filename_seq,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.seq']); %copy the seq file in the upper folder
+                if ~success
+                    disp(errormsg)
+                end
                 [success,errormsg] = copyfile(filename_sqb,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.sqb']); %copy the sqb file in the upper folder
+                if ~success
+                    disp(errormsg)
+                end
                 if check_xml
                     [success,errormsg] = copyfile(filexml,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.xml']); %copy the original xml file in the upper folder
+                if ~success
+                    disp(errormsg)
+                end
                 else
-                    errormsg=[filexml ' missing'];
+                    disp(['error:' filexml ' missing']);
                     return
                 end
Index: /trunk/src/transform_field/FFT2_detrend.m
===================================================================
--- /trunk/src/transform_field/FFT2_detrend.m	(revision 1112)
+++ /trunk/src/transform_field/FFT2_detrend.m	(revision 1113)
@@ -85,4 +85,7 @@
         DataOut.ListVarName=[CoordName {VarName}];%list of variables
         DataOut.VarDimName=[CoordName {CoordName}];%list of dimensions for variables
+        DataOut.VarAttribute{1}.Role='coord_y';
+        DataOut.VarAttribute{2}.Role='coord_x';
+        DataOut.VarAttribute{3}.Role='scalar';
         break
     end
Index: /trunk/src/xml2struct.m
===================================================================
--- /trunk/src/xml2struct.m	(revision 1112)
+++ /trunk/src/xml2struct.m	(revision 1113)
@@ -84,7 +84,7 @@
     case 'char' 
         % try to convert to number if the char does not correspond to a function (otherwise str2num calls this function as it uses 'eval')
-        if exist(ss,'builtin')||exist(ss,'file')% ss corresponds to the name of a builtin Matlab function or a file
-            out=ss; %reproduce the input string
-        else
+%         if exist(ss,'builtin')||exist(ss,'file')% ss corresponds to the name of a builtin Matlab function or a file
+%             out=ss; %reproduce the input string
+%         else
             out=str2num(ss);% convert to number or vector (str2num applied to a fct name executes this fct by 'eval', thus this possibility had to be ruled out above
             if isempty(out)
@@ -100,5 +100,5 @@
                 end
             end
-        end
+%         end
     case 'cell'
         out={};%default
