Index: /trunk/src/get_field.m
===================================================================
--- /trunk/src/get_field.m	(revision 433)
+++ /trunk/src/get_field.m	(revision 434)
@@ -56,7 +56,5 @@
 %% Update handles structure
 guidata(hObject, handles);
-
-%%activate the mouse action function: visualise the current field on work space by right click action
-%set(hObject,'WindowButtonUpFcn',{@mouse_up_gui,handles})
+set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
 
 %% prepare the list of RUN fcts and set their paths
@@ -144,4 +142,11 @@
     end
 end
+
+%% put the GUI on the lower right of the sceen
+pos_view_field=get(hObject,'Position');
+ScreenSize=get(0,'ScreenSize');
+pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3);
+pos_view_field(2)=ScreenSize(2);
+set(hObject,'Position',pos_view_field)
 
 %% remove already opened get_field GUI with name get_field
Index: /trunk/src/plot_field.m
===================================================================
--- /trunk/src/plot_field.m	(revision 433)
+++ /trunk/src/plot_field.m	(revision 434)
@@ -227,5 +227,9 @@
 if ~isempty(htext)
     if isempty(index_0D)
-        set(htext,'String',{''})
+        if strcmp(get(htext,'Type'),'uitable')
+            set(htext,'Data',{})
+        else
+            set(htext,'String',{''})
+        end
     else
         [errormsg]=plot_text(Data,CellVarIndex(index_0D),VarType(index_0D),htext);
Index: /trunk/src/read_get_field.m
===================================================================
--- /trunk/src/read_get_field.m	(revision 433)
+++ /trunk/src/read_get_field.m	(revision 434)
@@ -768,10 +768,10 @@
     for ilist=1:numel(VarIndex_y)
         VarName=Field.ListVarName{VarIndex_y(ilist)};
-        eval(['npxy=size(SubField.' VarName ');'])
+        npxy=size(SubField.(VarName));
         ind_select=find(npxy~=1);
         SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}(ind_select);
-        eval(['SubField.' VarName '=squeeze(SubField.' VarName ');'])%remove singleton dimensions
+        SubField.(VarName)=squeeze(SubField.(VarName));%remove singleton dimensions
         if testpermute(ilist)
-            eval(['SubField.' VarName '=permute(SubField.' VarName ',[2 1]);'])
+            SubField.(VarName)=permute(SubField.(VarName),[2 1]);
             SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}([2 1]);
         end
Index: /trunk/src/test_tps.m
===================================================================
--- /trunk/src/test_tps.m	(revision 434)
+++ /trunk/src/test_tps.m	(revision 434)
@@ -0,0 +1,32 @@
+x=2*pi*rand(100,1);%set of random x coordinates from 0 to 2pi
+y=2*pi*rand(100,1);%set of random y coordinates
+%U=exp(-(x-pi).*(x-pi)-(y-pi).*(y-pi));% gaussian
+U=x;
+[U_smooth,U_tps]=tps_coeff([x y],U,0);%calculate tps coeff
+xI=0:0.1:2*pi;%interpolation grid
+yI=0:0.1:2*pi;
+[XI,YI]=meshgrid(xI,yI);
+[npy,npx]=size(XI);
+XI=reshape(XI,[],1);
+YI=reshape(YI,[],1);
+EM = tps_eval([XI YI],[x y]);%evaluate interpolation on the new grid
+U_eval=EM*U_tps;
+U_eval=reshape(U_eval,npy,npx);
+figure(1)
+imagesc(U_eval,[-1 1])
+[DMX,DMY] = tps_eval_dxy([XI YI],[x y]);
+DUX_eval=DMX*U_tps;
+DUY_eval=DMY*U_tps;
+DUX_eval=reshape(DUX_eval,npy,npx);
+% plot(yI,U_eval(:,5))
+figure(2)
+DUY_eval=reshape(DUY_eval,npy,npx);
+imagesc(DUX_eval,[-1 1])
+% plot(xI,DU_eval(:,5))
+figure(3)
+imagesc(DUY_eval,[-1 1])
+figure(4)
+% plot(x,U_eval(50,:),x,DUX_eval(50,:),x,DUY_eval(50,:))
+size(U_eval(50,:))
+size(xI)
+plot(xI,U_eval(50,:),xI,DUX_eval(50,:),xI,DUY_eval(50,:))
Index: /trunk/src/tps_coeff.m
===================================================================
--- /trunk/src/tps_coeff.m	(revision 433)
+++ /trunk/src/tps_coeff.m	(revision 434)
@@ -9,5 +9,5 @@
 % EMDX and EMDY are obtained from the function tps_eval_dxy.
 %------------------------------------------------------------------------
-% [U_smooth,U_tps]=tps_coeff(ctrs,U,rho)
+% [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
 %------------------------------------------------------------------------
 % OUPUT:
@@ -16,12 +16,12 @@
 
 %INPUT:
-% ctrs: Nxs matrix  representing the postions of the M centers, sources of the tps (s=space dimension)
-% U: Nx1 column vector representing the initial values of the considered scalar at the centres ctrs
-% rho: smoothing parameter: the result is smoother for larger rho.
+% ctrs: Nxs matrix  representing the postions of the N centers, sources of the tps (s=space dimension)
+% U: Nx1 column vector representing the values of the considered scalar measured at the centres ctrs
+% Smoothing: smoothing parameter: the result is smoother for larger Smoothing.
 
 
-function [U_smooth,U_tps]=tps_coeff(ctrs,U,rho)
+function [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
 %------------------------------------------------------------------------
-%rho smoothing parameter
+%Smoothing smoothing parameter
 % X=reshape(X,[],1);
 % Y=reshape(Y,[],1);
@@ -31,8 +31,8 @@
 % ctrs = [X Y];% coordinates of measurement sites, radial base functions are located at the measurement sites
 EM = tps_eval(ctrs,ctrs);
-RhoMat=rho*eye(N,N);%  rho=1/(2*omega) , omega given by fasshauer;
-RhoMat=[RhoMat zeros(N,3)];
+SmoothingMat=Smoothing*eye(N,N);%  Smoothing=1/(2*omega) , omega given by fasshauer;
+SmoothingMat=[SmoothingMat zeros(N,3)];
 PM=[ones(N,1) ctrs];
-IM=[EM+RhoMat; [PM' zeros(3,3)]];
+IM=[EM+SmoothingMat; [PM' zeros(3,3)]];
 U_tps=(IM\U);
 U_smooth=EM *U_tps;
Index: /trunk/src/tps_eval.m
===================================================================
--- /trunk/src/tps_eval.m	(revision 433)
+++ /trunk/src/tps_eval.m	(revision 434)
@@ -1,4 +1,4 @@
 %'tps_eval': calculate the thin plate spline (tps) interpolation at a set of points
-% see tps_ceff for more information
+% see tps_coeff.m for more information and test_tps.m for an example
 %------------------------------------------------------------------------
 % function EM = tps_eval(dsites,ctrs)
@@ -8,8 +8,9 @@
 %   from unit sources located at each of the N centers, + (s+1) columns
 %   representing the contribution of the linear gradient part.
+%  use : U_interp=EM*U_tps
 %
 %INPUT:
-%dsites:  Nxs matrix representing the postions of the N 'observation' sites, with s the space dimension
-%ctrs: Mxs matrix  representing the postions of the M centers, sources of the tps,
+%dsites:  Mxs matrix representing the postions of the M 'observation' sites, with s the space dimension
+%ctrs: Nxs matrix  representing the postions of the N centers, sources of the tps,
 %
 % related functions:
Index: /trunk/src/tps_eval_dxy.m
===================================================================
--- /trunk/src/tps_eval_dxy.m	(revision 433)
+++ /trunk/src/tps_eval_dxy.m	(revision 434)
@@ -31,7 +31,7 @@
   
 [Dsites,Ctrs] = ndgrid(dsites(:,1),ctrs(:,1));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)
-DX=Dsites-Ctrs;
+DX=Dsites-Ctrs;% set of x wise distances between sites and centres
 [Dsites,Ctrs] = ndgrid(dsites(:,2),ctrs(:,2));%d coordinates of interpolation points (Dsites) and initial points (Ctrs)
-DY=Dsites-Ctrs;
+DY=Dsites-Ctrs;% set of y wise distances between sites and centres
 DM = DX.*DX + DY.*DY;% add d component squared 
 
@@ -40,4 +40,4 @@
 
 DMX=[DX.*DM zeros(M,1)  ones(M,1) zeros(M,1)];% effect of mean gradient
-DMY=[DY.*DM zeros(M,1)  ones(M,1) zeros(M,1)];% effect of mean gradient
+DMY=[DY.*DM zeros(M,1)  zeros(M,1) ones(M,1)];% effect of mean gradient
 
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 433)
+++ /trunk/src/uvmat.m	(revision 434)
@@ -2170,5 +2170,4 @@
 
 %% update the display menu for the second velocity type (second menuline)
-
 test_veltype_1=0;
 if isempty(filename_1)
@@ -2235,6 +2234,4 @@
 end           
 
-
-
 %% display time
 testimedoc=0;
@@ -2390,16 +2387,15 @@
 %UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation
 
-
-%% get bounds and mesh (needed for mouse action and to open set_object)
+%% analyse input field
 test_x=0;
 test_z=0;% test for unstructured z coordinate
-[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);
+[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure
 if ~isempty(errormsg)
-    errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];
+    errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error
     return
 end
-[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);
+[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);% analyse  the input field structure
 if ~isempty(errormsg)
-    errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];
+    errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];% display error
     return
 end
@@ -2408,43 +2404,42 @@
     NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
 end
+
+%% get bounds and mesh (needed for mouse action and to open set_object)
 XName=''; %default
 YName='';
-if ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinates
+if ~isempty(VarType{imax}.coord_x)
     XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
-    YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
-    nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors)
-    test_x=1;%test for unstructured coordinates
-    if ~isempty(VarType{imax}.coord_z)
-        ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
-    else
-        NbDim=2;
-    end
-elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate
+    DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
+    nbpoints_x=DimValue(DimIndex(NbDim));
+      %unstructured coordinates
+    if ~isempty(VarType{imax}.coord_y)  
+        YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
+        %nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors)
+        test_x=1;%test for unstructured coordinates
+        if ~isempty(VarType{imax}.coord_z)
+            ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
+        else
+            NbDim=2;
+        end
+    end
+%structured coordinate   
+elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 
     XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
     if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0
         YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
     end
-    VarIndex=CellVarIndex{imax}; % list of variable indices
-    DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
+   % VarIndex=CellVarIndex{imax}; % list of variable indices
+    DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable
     nbpoints_x=DimValue(DimIndex(NbDim));
     XMax=nbpoints_x;%default
     XMin=1;%default
 end
-%% object visibility
-if NbDim>=2
-    set(handles.Objects,'Visible','on')
-    set(handles.ListObject_1_title,'Visible','on')
-    set(handles.ListObject_1,'Visible','on')
-else% usual (x,y) plots: no projection object
-    set(handles.Objects,'Visible','off')
-    set(handles.ListObject_title,'Visible','off')
-    set(handles.ListObject_1,'Visible','off')
-end
+
 if NbDim==3
     if ~test_x
         ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
     end
-    eval(['ZMax=max(UvData.Field.' ZName ');'])
-    eval(['ZMin=min(UvData.Field.' ZName ');'])
+    ZMax=max(UvData.Field.(ZName));
+    ZMin=min(UvData.Field.(ZName));
     UvData.Field.ZMax=ZMax;
     UvData.Field.ZMin=ZMin;
@@ -2455,5 +2450,4 @@
     end
 end
-
 if ~isempty (XName)
     XMax=max(max(UvData.Field.(XName)));
@@ -2478,8 +2472,6 @@
     end
 end
+% case of structured coordinates
 if ~test_x
-    %         VarIndex=CellVarIndex{imax}; % list of variable indices
-    %         DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
-    %         nbpoints_x=DimValue(DimIndex(NbDim));
     DX=(XMax-XMin)/(nbpoints_x-1);
     if NbDim >1
@@ -2512,8 +2504,8 @@
     UvData.Field.Mesh=ord;
 end
-        UvData.Object{1}.Type='plane';%main plotting plane
-        UvData.Object{1}.ProjMode='projection';%main plotting plane
-        UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
-        UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
+UvData.Object{1}.Type='plane';%main plotting plane
+UvData.Object{1}.ProjMode='projection';%main plotting plane
+UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
+UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
 
 %% 3D case (menuvolume)
@@ -2528,8 +2520,4 @@
     if test_set_object% reinitiate the GUI set_object
         delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
-%         UvData.Object{1}.Type='plane';%main plotting plane
-%         UvData.Object{1}.ProjMode='projection';%main plotting plane
-%         UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
-%         UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
         UvData.Object{1}.NbDim=NbDim;%test for 3D objects
         UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
@@ -2560,17 +2548,4 @@
         UvData.Object{1}.ZObject=UvData.ZIndex;
     end
-else
-%     % create a default projection
-%     UvData.Object{1}.ProjMode='projection';%main plotting plane
-%     UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
-%     set(handles.ListObject,'Value',1);
-%     list_object=get(handles.ListObject,'String');
-%     if isempty(list_object)
-%         list_object={''};
-%     elseif ~isempty(list_object{1})
-%         list_object=[{''};list_object];
-%     end
-%     set(handles.ListObject,'String',list_object);
-% %     set(handles.list_object_2,'String',list_object);
 end
 testnewseries=UvData.NewSeries;
@@ -2584,203 +2559,204 @@
 % end
 
-%% Plot the projections on the selected  projection objects
-% main projection object (uvmat display)
-list_object=get(handles.ListObject_1,'String');
-if isequal(list_object,{''})%refresh list of objects if the menu is empty
-    UvData.Object={[]}; 
-    set(handles.ListObject_1,'Value',1)
-end
-IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
-if IndexObj(1)> numel(UvData.Object)
-    IndexObj(1)=1;%select the first object if the selected one does not exist
-    set(handles.ListObject_1,'Value',1)
-end
-IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view
-if isequal(IndexObj(2),IndexObj(1))
-    IndexObj(2)=[];
-end
-plot_handles{1}=handles;
-if isfield(UvData,'plotaxes')%case of movies
-    haxes(1)=UvData.plotaxes;
-else
-    haxes(1)=handles.axes3;
-end
-%PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
-PlotParam{1}=read_GUI(handles.uvmat);
-%default settings if vectors not visible 
-if ~isfield(PlotParam{1},'Vectors')
-    PlotParam{1}.Vectors.MaxVec=1;
-    PlotParam{1}.Vectors.MinVec=0;
-    PlotParam{1}.Vectors.CheckFixVecColor=1;
-    PlotParam{1}.Vectors.ColCode1=0.33;
-    PlotParam{1}.Vectors.ColCode2=0.66;
-    PlotParam{1}.Vectors.ColorScalar={'ima_cor'};
-    PlotParam{1}.Vectors.ColorCode= {'rgb'};
-end
-%keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits
-PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
-
-% second projection object (view_field display)
-if length( IndexObj)>=2
-    view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
-    if ~isempty(view_field_handle)
-        plot_handles{2}=guidata(view_field_handle);
-        haxes(2)=plot_handles{2}.axes3;
-        PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface
-        PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
-    end
-end
-
-%% loop on the projection objects: one or two
-for imap=1:numel(IndexObj)
-    iobj=IndexObj(imap);
-%      if imap==2 || check_proj==0  % field not yet projected) && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
-% %          [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field);
-% %      else
+%% usual 1D (x,y) plots
+if NbDim<=1
+    set(handles.Objects,'Visible','off')
+    set(handles.ListObject_1_title,'Visible','off')
+    set(handles.ListObject_1,'Visible','off')
+    [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.axes3,read_GUI(handles.uvmat));
+    write_plot_param(handles,PlotParamOut) %update the auto plot parameters
+%     if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
+%         ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
+%     end
+    
+%% 2D or 3D fields are generally projected
+else
+    set(handles.Objects,'Visible','on')
+    set(handles.ListObject_1_title,'Visible','on')
+    set(handles.ListObject_1,'Visible','on')
+    
+    %% Plot the projections on the selected  projection objects
+    % main projection object (uvmat display)
+    list_object=get(handles.ListObject_1,'String');
+    if isequal(list_object,{''})%refresh list of objects if the menu is empty
+        UvData.Object={[]};
+        set(handles.ListObject_1,'Value',1)
+    end
+    IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
+    if IndexObj(1)> numel(UvData.Object)
+        IndexObj(1)=1;%select the first object if the selected one does not exist
+        set(handles.ListObject_1,'Value',1)
+    end
+    IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view
+    if isequal(IndexObj(2),IndexObj(1))
+        IndexObj(2)=[];
+    end
+    plot_handles{1}=handles;
+    if isfield(UvData,'plotaxes')%case of movies
+        haxes(1)=UvData.plotaxes;
+    else
+        haxes(1)=handles.axes3;
+    end
+    PlotParam{1}=read_GUI(handles.uvmat);
+    %default settings if vectors not visible
+    if ~isfield(PlotParam{1},'Vectors')
+        PlotParam{1}.Vectors.MaxVec=1;
+        PlotParam{1}.Vectors.MinVec=0;
+        PlotParam{1}.Vectors.CheckFixVecColor=1;
+        PlotParam{1}.Vectors.ColCode1=0.33;
+        PlotParam{1}.Vectors.ColCode2=0.66;
+        PlotParam{1}.Vectors.ColorScalar={'ima_cor'};
+        PlotParam{1}.Vectors.ColorCode= {'rgb'};
+    end
+    PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
+    
+    %% second projection object (view_field display)
+    if length( IndexObj)>=2
+        view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
+        if ~isempty(view_field_handle)
+            plot_handles{2}=guidata(view_field_handle);
+            haxes(2)=plot_handles{2}.axes3;
+            PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface
+            PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
+        end
+    end
+    
+    %% loop on the projection objects: one or two
+    
+    for imap=1:numel(IndexObj)
+        iobj=IndexObj(imap);
+        %      if imap==2 || check_proj==0  % field not yet projected) && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
+        % %          [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field);
+        % %      else
         [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
-%      end
-    if ~isempty(errormsg)
-        return
-    end
-    if testnewseries 
-        PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar)
-        if isfield(ObjectData,'CoordUnit')
-        PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y)
-        PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1
-        end
-    end
-    %use of mask (TODO: check)
-    if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
-        flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
-        AX=ObjectData.AX;%x coordiantes for the scalar field
-        AY=ObjectData.AY;%y coordinates for the scalar field
-        MaskX=ObjectData.MaskX;%x coordiantes for the mask
-        MaskY=ObjectData.MaskY;%y coordiantes for the mask
-        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
-            %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,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
-            flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
-        end
-        AClass=class(ObjectData.A);
-        ObjectData.A=flag_mask.*double(ObjectData.A);
-        ObjectData.A=feval(AClass,ObjectData.A);
-        ind_off=[];
-        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')
-                    ind_off=[ind_off ilist];
+        %      end
+        if ~isempty(errormsg)
+            return
+        end
+        if testnewseries
+            PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar)
+            if isfield(ObjectData,'CoordUnit')
+                PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y)
+                PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1
+            end
+        end
+        %use of mask (TODO: check)
+        if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
+            flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
+            AX=ObjectData.AX;%x coordiantes for the scalar field
+            AY=ObjectData.AY;%y coordinates for the scalar field
+            MaskX=ObjectData.MaskX;%x coordiantes for the mask
+            MaskY=ObjectData.MaskY;%y coordiantes for the mask
+            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
+                %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,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
+                flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
+            end
+            AClass=class(ObjectData.A);
+            ObjectData.A=flag_mask.*double(ObjectData.A);
+            ObjectData.A=feval(AClass,ObjectData.A);
+            ind_off=[];
+            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')
+                        ind_off=[ind_off ilist];
+                    end
+                end
+                ObjectData.ListVarName(ind_off)=[];
+                VarDimIndex(ind_off)=[];
+                ind_off=[];
+                for ilist=1:length(ListDimName)
+                    if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY')
+                        ind_off=[ind_off ilist];
+                    end
+                end
+                ListDimName(ind_off)=[];
+                DimValue(ind_off)=[];
+            end
+        end
+        if ~isempty(ObjectData)
+            PlotType='none'; %default
+            if imap==2 && isempty(view_field_handle)
+                view_field(ObjectData)
+            else
+                [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
+                write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
+                if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
+                    ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
                 end
             end
-            ObjectData.ListVarName(ind_off)=[];
-            VarDimIndex(ind_off)=[];
-            ind_off=[];
-            for ilist=1:length(ListDimName)
-                if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY')
-                    ind_off=[ind_off ilist];
+            if isequal(PlotType,'none')
+                hget_field=findobj(allchild(0),'name','get_field');
+                if isempty(hget_field)
+                    get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
                 end
+                errormsg='The field defined by get_field cannot be plotted';
+                return
             end
-            ListDimName(ind_off)=[];
-            DimValue(ind_off)=[];
-        end
-    end
-    if ~isempty(ObjectData)
-        
-        PlotType='none'; %default
-        if imap==2 && isempty(view_field_handle)
-            view_field(ObjectData)
-        else
-            [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
-            write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
-            if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
-                ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
+        end
+    end
+    
+    %% update the mask
+    if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
+        update_mask(handles,num_i1,num_i2);
+    end
+    
+    %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
+    menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
+    ind_skip=[];
+    % nb_histo=1;
+    Ustring='';
+    Vstring='';
+    % suppress coordinates from the histogram menu
+    for ivar=1:numel(menu_histo)%l loop on field variables:
+        if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
+            Role=UvData.Field.VarAttribute{ivar}.Role;
+            switch Role
+                case {'coord_x','coord_y','coord_z','dimvar'}
+                    ind_skip=[ind_skip ivar];
+                case {'vector_x'}
+                    Ustring=UvData.Field.ListVarName{ivar};
+                    ind_skip=[ind_skip ivar];
+                case {'vector_y'}
+                    Vstring=UvData.Field.ListVarName{ivar};
+                    ind_skip=[ind_skip ivar];
             end
         end
-        if isequal(PlotType,'none')
-            hget_field=findobj(allchild(0),'name','get_field');
-            if isempty(hget_field)
-                get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
-            end
-            errormsg='The field defined by get_field cannot be plotted';
-            return
-        end
-    end
-end
-
-%% update the mask
-if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
-   update_mask(handles,num_i1,num_i2);
-end
-
-%% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
-menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
-ind_skip=[];
-% nb_histo=1;
-Ustring='';
-Vstring='';
-% suppress coordinates from the histogram menu
-for ivar=1:numel(menu_histo)%l loop on field variables:
-    if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
-        Role=UvData.Field.VarAttribute{ivar}.Role;
-        switch Role
-            case {'coord_x','coord_y','coord_z','dimvar'}
-                ind_skip=[ind_skip ivar];
-            case {'vector_x'}
-                Ustring=UvData.Field.ListVarName{ivar};
-                ind_skip=[ind_skip ivar];
-            case {'vector_y'}
-                Vstring=UvData.Field.ListVarName{ivar};
-                ind_skip=[ind_skip ivar];
-        end
-    end
-    DimCell=UvData.Field.VarDimName{ivar};
-    DimName='';
-    if ischar(DimCell)
-        DimName=DimCell;
-    elseif iscell(DimCell)&& numel(DimCell)==1
-        DimName=DimCell{1};
-    end
-    if strcmp(DimName,menu_histo{ivar})
-        ind_skip=[ind_skip ivar];
-    end
-end
-menu_histo(ind_skip)=[];% remove skipped items
-if ~isempty(Ustring)
-    menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% display menus and plot histograms
-test_v=0;
-if ~isempty(menu_histo)
-    set(handles.histo1_menu,'Value',1)
-    set(handles.histo1_menu,'String',menu_histo)
-    histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram 
-    % case of more than one variables (eg vector components)
-%     if nb_histo > 1 
-%         test_v=1;
-%         set(handles.histo2_menu,'Visible','on')
-%         set(handles.histo_v,'Visible','on')
-%         set(handles.histo2_menu,'String',menu_histo)
-%         set(handles.histo2_menu,'Value',2)
-%         histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram 
-%     end
-end
-% if ~test_v
-%     set(handles.histo2_menu,'Visible','off')
-%     set(handles.histo_v,'Visible','off')
-%     cla(handles.histo_v)
-%     set(handles.histo2_menu,'Value',1)
-% end
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+        DimCell=UvData.Field.VarDimName{ivar};
+        DimName='';
+        if ischar(DimCell)
+            DimName=DimCell;
+        elseif iscell(DimCell)&& numel(DimCell)==1
+            DimName=DimCell{1};
+        end
+        if strcmp(DimName,menu_histo{ivar})
+            ind_skip=[ind_skip ivar];
+        end
+    end
+    menu_histo(ind_skip)=[];% remove skipped items
+    if ~isempty(Ustring)
+        menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist
+    end
+    
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+    % display menus and plot histograms
+    test_v=0;
+    if ~isempty(menu_histo)
+        set(handles.histo1_menu,'Value',1)
+        set(handles.histo1_menu,'String',menu_histo)
+        histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
+    end
+end
+
 %------------------------------------------------------------------------
 function histo1_menu_Callback(hObject, eventdata, handles)
