Index: /trunk/src/mouse_motion.m
===================================================================
--- /trunk/src/mouse_motion.m	(revision 971)
+++ /trunk/src/mouse_motion.m	(revision 972)
@@ -224,7 +224,13 @@
                     sin_om=sin(pi*om/180);
                     pos=[xy(1,1) xy(1,2) 0];
-                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
-                end
-               pos=pos+Field.ProjObjectCoord;
+                    %pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
+                    coeff=OmAxis(3)*(1-cos_om);
+                    norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
+                    norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
+                    norm_plane(3)=OmAxis(3)*coeff+cos_om;
+                    %Z0=norm_plane*Field.ProjObjectCoord'/norm_plane(3);
+                    pos(3)=-(norm_plane(1)*pos(1)-norm_plane(2)*pos(2))/norm_plane(3);                               
+                end
+                pos=pos+Field.ProjObjectCoord;
                 text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
             end
Index: /trunk/src/phys_XYZ.m
===================================================================
--- /trunk/src/phys_XYZ.m	(revision 971)
+++ /trunk/src/phys_XYZ.m	(revision 972)
@@ -41,8 +41,8 @@
         norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
         norm_plane(3)=OmAxis(3)*coeff+cos_om;
-        Z0=norm_plane*Calib.SliceCoord(Zindex,:)'/norm_plane(3);
-    else
+%         Z0=norm_plane*Calib.SliceCoord(Zindex,:)'/norm_plane(3);
+    end
         Z0=Calib.SliceCoord(Zindex,3);%horizontal plane z=cte
-    end
+%     end
     Z0virt=Z0;
     if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex')
Index: /trunk/src/phys_ima.m
===================================================================
--- /trunk/src/phys_ima.m	(revision 971)
+++ /trunk/src/phys_ima.m	(revision 972)
@@ -61,27 +61,30 @@
         [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation
         [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,ZIndex);
-    else         
+    else
         % the image needs to be interpolated to the new coordinates
         zphys=0; %default
         if isfield(Calib,'SliceCoord') %.Z= index of plane
-           SliceCoord=Calib.SliceCoord(ZIndex,:);
-           zphys=SliceCoord(3); %to generalize for non-parallel planes
-           
-%         if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0])
-%                     om=norm(Calib.SliceAngle);%norm of rotation angle in radians
-%                     OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis
-%                     cos_om=cos(pi*om/180);
-%                     sin_om=sin(pi*om/180);
-%                     pos=[xy(1,1) xy(1,2) 0];
-%                     pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
-%                 end
-           
-           
-%            if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex') 
+            SliceCoord=Calib.SliceCoord(ZIndex,:);
+            zphys=SliceCoord(3); %to generalize for non-parallel planes
+            if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0]) && ~isequal(Calib.SliceAngle(ZIndex,:),[0 0 0])
+                testangle=1;
+                om=norm(Calib.SliceAngle(ZIndex,:));%norm of rotation angle in radians
+                OmAxis=Calib.SliceAngle(ZIndex,:)/om; %unit vector marking the rotation axis
+                cos_om=cos(pi*om/180);
+                sin_om=sin(pi*om/180);
+                coeff=OmAxis(3)*(1-cos_om);
+                norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
+                norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
+                norm_plane(3)=OmAxis(3)*coeff+cos_om;
+                %Z0=norm_plane*Calib.SliceCoord(ZIndex,:)'/norm_plane(3);
+                Z0=Calib.SliceCoord(ZIndex,3);
+                zphys=Z0-(norm_plane(1)*X-norm_plane(2)*Y)/norm_plane(3);
+            end
+%             if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex')
 %                 H=Calib.InterfaceCoord(3);
 %                 if H>zphys
 %                     zphys=H-(H-zphys)/Calib.RefractionIndex; %corrected z (virtual object)
 %                 end
-%            end
+%             end
         end
         xima=0.5:npx(icell)-0.5;%image coordinates of corners
Index: /trunk/src/series.m
===================================================================
--- /trunk/src/series.m	(revision 971)
+++ /trunk/src/series.m	(revision 972)
@@ -2714,4 +2714,5 @@
 end
 
+
 function [TimeValue,DtValue]=get_time(ref_i,ref_j,PairString,InputTable,FileInfo,TimeName,DtName)
 [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString);
@@ -3486,5 +3487,5 @@
 
 % --- Executes on button press in SetPairs.
-function SetPairs_Callback(hObject, iview, handles)
+function SetPairs_Callback(hObject, eventdata, handles)
 
 %% delete previous occurrence of 'set_pairs'
@@ -3510,4 +3511,5 @@
 ListViewLines=find(cellfun('isempty',PairString)==0);%find list of non empty pairs
 ListViewMenu=cell(numel(ListViewLines),1);
+iview=get(handles.PairString,'Value');
 for ilist=1:numel(ListViewLines)
     ListViewMenu{ilist}=num2str(ListViewLines(ilist));
Index: /trunk/src/series/extract_multitif.m
===================================================================
--- /trunk/src/series/extract_multitif.m	(revision 971)
+++ /trunk/src/series/extract_multitif.m	(revision 972)
@@ -59,5 +59,5 @@
 %=======================================================================
 
-function ParamOut=ima2netcdf(Param)
+function ParamOut=extract_multitif(Param)
 
 %%%%%%%%%%%%%%%%%    INPUT PREPARATION MODE (no RUN)    %%%%%%%%%%%%%%%%%
@@ -73,5 +73,5 @@
     ParamOut.OutputDirExt='.png';%set the output dir extension
     ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
-    
+     ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)
     %% root input file(s) and type
     % check the existence of the first file in the series
@@ -148,5 +148,5 @@
 %count=316;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP08: 4684 images -> start at 316 start 67->_11_1
 %count=1934%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP07: 3066 images
-%% loop on the files 
+%% loop on the files  
 for ifile=1:numel(ListFile)
     update_waitbar(WaitbarHandle,ifile/numel(ListFile))
@@ -158,19 +158,48 @@
     NbFrames=numel(imfinfo(ImageName));
     % loop on the frames within the tiff file
-    for iframe=1:NbFrames      
-        A=imread(ImageName,iframe);
-
-        if isequal(ImagesPerLevel,1)% mode series 
+    for iframe=1:NbFrames       
+        if isequal(ImagesPerLevel,1)% mode series
             i_index=count+1;
             OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']);
-        else % indices i and j 
+        else % indices i and j
             i_index=fix(count/ImagesPerLevel)+1;
             j_index=mod(count,ImagesPerLevel)+1;
             OutputFile=fullfile(OutputDir,['img_' num2str(i_index) '_' num2str(j_index) '.png']);
         end
-        imwrite(A,OutputFile,'BitDepth',16)
+        if Param.CheckOverwrite ||~exist(OutputFile,'file')
+            A=imread(ImageName,iframe);
+            imwrite(A,OutputFile,'BitDepth',16);
+            disp([OutputFile ' written'])
+        else
+            disp([OutputFile ' already exists'])
+        end
         count=count+1;
     end
 end
+
+% for ifile=1:numel(ListFile)
+%     update_waitbar(WaitbarHandle,ifile/numel(ListFile))
+%     if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')
+%         disp('program stopped by user')
+%         break
+%     end
+%     ImageName=fullfile(DirImages,ListFile{ifile});
+%     NbFrames=numel(imfinfo(ImageName));
+%     % loop on the frames within the tiff file
+%     for iframe=1:NbFrames      
+%         A=imread(ImageName,iframe);
+% 
+%         if isequal(ImagesPerLevel,1)% mode series 
+%             i_index=count+1;
+%             OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']);
+%         else % indices i and j 
+%             i_index=fix(count/ImagesPerLevel)+1;
+%             j_index=mod(count,ImagesPerLevel)+1;
+%             OutputFile=fullfile(OutputDir,['img_' num2str(i_index) '_' num2str(j_index) '.png']);
+%         end
+%         imwrite(A,OutputFile,'BitDepth',16)
+%         count=count+1;
+%     end
+% end
 
 %% create the xml file of PCO camera
@@ -181,7 +210,7 @@
 
 %% remove initial files if transfer OK
-    if i_index== (size(XmlInput.Time,1)-1)
-
-        [SUCCESS,MESSAGE]=rmdir(DirImages,'s')
-       
-    end
+%     if i_index== (size(XmlInput.Time,1)-1)
+% 
+%         [SUCCESS,MESSAGE]=rmdir(DirImages,'s')
+%        
+%     end
Index: /trunk/src/series/extract_multitif_parallel.m
===================================================================
--- /trunk/src/series/extract_multitif_parallel.m	(revision 972)
+++ /trunk/src/series/extract_multitif_parallel.m	(revision 972)
@@ -0,0 +1,234 @@
+%'ima2netcdf': read image series and transform to netcdf
+%------------------------------------------------------------------------
+
+    
+% function ParamOut=ima2netcdf(Param)
+%
+%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%OUTPUT
+% ParamOut: sets options in the GUI series.fig needed for the function
+%
+%INPUT:
+% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
+% In batch mode, Param is the name of the corresponding xml file containing the same information
+% when Param.Action.RUN=0 (as activated when the current Action is selected
+% in series), the function ouput paramOut set the activation of the needed GUI elements
+%
+% Param contains the elements:(use the menu bar command 'export/GUI config' in series to 
+% see the current structure Param)
+%    .InputTable: cell of input file names, (several lines for multiple input)
+%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
+%    .OutputSubDir: name of the subdirectory for data outputs
+%    .OutputDirExt: directory extension for data outputs
+%    .Action: .ActionName: name of the current activated function
+%             .ActionPath:   path of the current activated function
+%             .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled   Matlab fct
+%             .RUN =0 for GUI input, =1 for function activation
+%             .RunMode='local','background', 'cluster': type of function  use
+%             
+%    .IndexRange: set the file or frame indices on which the action must be performed
+%    .FieldTransform: .TransformName: name of the selected transform function
+%                     .TransformPath:   path  of the selected transform function
+%    .InputFields: sub structure describing the input fields withfields
+%              .FieldName: name(s) of the field
+%              .VelType: velocity type
+%              .FieldName_1: name of the second field in case of two input series
+%              .VelType_1: velocity type of the second field in case of two input series
+%              .Coord_y: name of y coordinate variable
+%              .Coord_x: name of x coordinate variable
+%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%=======================================================================
+% Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
+%   http://www.legi.grenoble-inp.fr
+%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
+%
+%     This file is part of the toolbox UVMAT.
+%
+%     UVMAT is free software; you can redistribute it and/or modify
+%     it under the terms of the GNU General Public License as published
+%     by the Free Software Foundation; either version 2 of the license,
+%     or (at your option) any later version.
+%
+%     UVMAT is distributed in the hope that it will be useful,
+%     but WITHOUT ANY WARRANTY; without even the implied warranty of
+%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%     GNU General Public License (see LICENSE.txt) for more details.
+%=======================================================================
+
+function ParamOut=ima2netcdf(Param)
+
+%%%%%%%%%%%%%%%%%    INPUT PREPARATION MODE (no RUN)    %%%%%%%%%%%%%%%%%
+if isstruct(Param) && isequal(Param.Action.RUN,0)
+    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
+    ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
+    ParamOut.NbSlice='off'; % impose calculation in a single process (no parallel processing to avoid 'holes'))
+    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
+    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
+    ParamOut.FieldTransform = 'off';%can use a transform function
+    ParamOut.ProjObject='off';%can use projection object(option 'off'/'on',
+    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
+    ParamOut.OutputDirExt='.png';%set the output dir extension
+    ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
+      ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)
+    %% root input file(s) and type
+    % check the existence of the first file in the series
+        first_j=[];% note that the function will propose to cover the whole range of indices
+    if isfield(Param.IndexRange,'MinIndex_j'); first_j=Param.IndexRange.MinIndex_j; end
+    last_j=[];
+    if isfield(Param.IndexRange,'MaxIndex_j'); last_j=Param.IndexRange.MaxIndex_j; end
+    PairString='';
+    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
+    [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
+    FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
+        Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
+    if ~exist(FirstFileName,'file')
+        msgbox_uvmat('WARNING',['the first input file ' FirstFileName ' does not exist'])
+    end
+
+    %% check the validity of  input file types
+    FileInfo=get_file_info(FirstFileName);
+    if ~strcmp(FileInfo.FileType,'multimage')
+        msgbox_uvmat('ERROR',['invalid file type input: ' FileInfo.FileType ' not an image'])
+        return
+    end
+    xmlinput=uigetfile_uvmat('pick xml file for timing',fileparts(fileparts(FirstFileName)),'.xml');
+    [tild,ParamOut.ActionInput.XmlFile]=fileparts(xmlinput);
+    ParamOut.ActionInput.XmlFile
+    
+    return
+end
+%%%%%%%%%%%%%%%%%    STOP HERE FOR PAMETER INPUT MODE   %%%%%%%%%%%%%%%%% 
+
+%% read input parameters from an xml file if input is a file name (batch mode)
+checkrun=1;
+RUNHandle=[];
+WaitbarHandle=[];
+if ischar(Param)
+    Param=xml2struct(Param);% read Param as input file (batch case)
+    checkrun=0;
+else
+    hseries=findobj(allchild(0),'Tag','series');
+    RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
+    WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
+end
+
+%% list of input images
+% DirImages=fullfile(Param.InputTable{1,1},Param.InputTable{1,2});
+% ListStruct=dir(DirImages);
+% ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
+% check_bad=strcmp('.',ListCells(1,:))|strcmp('..',ListCells(1,:));%detect the dir '.' to exclude it
+% check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
+% ListFile=ListCells(1,find(~check_dir & ~check_bad));
+
+%% check file names
+% RootName=regexprep(ListFile{1},'.tif$','')
+% rank(1)=1;
+% for ilist=2:numel(ListFile)
+%     rank_str=regexprep(ListFile{ilist},'.tif$','');
+%     rank(ilist)=regexprep(rank_str,['^' RootName '@'],'');
+% %     if ~isequal(str2num(rank),ilist-1)
+% %         disp(['error in the list of input file # ' num2str(ilist-1)])
+% %         return
+% %     end
+% end
+
+%% output directory
+OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);
+
+%% Timing
+XmlInputFile=fullfile(Param.InputTable{1,1},[Param.ActionInput.XmlFile '.xml'])
+XmlInput=imadoc2struct(XmlInputFile,'Camera');
+
+%% Main loop
+
+ImagesPerLevel=size(XmlInput.Time,2)-1;%100;
+% count=0;
+%count=316;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP08: 4684 images -> start at 316 start 67->_11_1
+%count=1934%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%CORRECTION EXP07: 3066 images
+%% loop on the files
+%for ifile=1:numel(ListFile)
+%     update_waitbar(WaitbarHandle,ifile/numel(ListFile))
+%     if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')
+%         disp('program stopped by user')
+%         break
+%     end
+%    ImageName=fullfile(DirImages,ListFile{ifile});
+%   NbFrames=numel(imfinfo(ImageName));
+% loop on the frames within the tiff file
+if Param.IndexRange.first_i==1% first slice of processing
+    firstindex=0;
+    count=0;
+else
+    firstindex=Param.IndexRange.first_i;
+    ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},'im.tif');
+    NbFrames=numel(imfinfo(ImageName));
+    count=Param.IndexRange.first_i*NbFrames;
+end
+for ifile=firstindex:Param.IndexRange.last_i
+    if firstindex==0 && ifile==0% first slice of processing
+            ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},'im.tif')
+    else
+        ImageName=fullfile(Param.InputTable{1,1},Param.InputTable{1,2},['im@' num2str(ifile,'%04d') '.tif'])
+    end
+    NbFrames=numel(imfinfo(ImageName));
+    for iframe=1:NbFrames
+        iframe
+        if isequal(ImagesPerLevel,1)% mode series
+            OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']);
+        else % indices i and j
+            i_index=fix(count/ImagesPerLevel)+1;
+            j_index=mod(count,ImagesPerLevel)+1;
+            OutputFile=fullfile(OutputDir,['img_' num2str(i_index) '_' num2str(j_index) '.png']);
+        end
+        if Param.CheckOverwrite ||~exist(OutputFile,'file')
+            A=imread(ImageName,iframe);
+            imwrite(A,OutputFile,'BitDepth',16);
+            disp([OutputFile ' written'])
+        else
+            disp([OutputFile ' already exists'])
+        end
+        count=count+1;
+    end
+end
+    %end
+
+% for ifile=1:numel(ListFile)
+%     update_waitbar(WaitbarHandle,ifile/numel(ListFile))
+%     if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')
+%         disp('program stopped by user')
+%         break
+%     end
+%     ImageName=fullfile(DirImages,ListFile{ifile});
+%     NbFrames=numel(imfinfo(ImageName));
+%     % loop on the frames within the tiff file
+%     for iframe=1:NbFrames      
+%         A=imread(ImageName,iframe);
+% 
+%         if isequal(ImagesPerLevel,1)% mode series 
+%             i_index=count+1;
+%             OutputFile=fullfile(OutputDir,['img_' num2str(count+1) '.png']);
+%         else % indices i and j 
+%             i_index=fix(count/ImagesPerLevel)+1;
+%             j_index=mod(count,ImagesPerLevel)+1;
+%             OutputFile=fullfile(OutputDir,['img_' num2str(i_index) '_' num2str(j_index) '.png']);
+%         end
+%         imwrite(A,OutputFile,'BitDepth',16)
+%         count=count+1;
+%     end
+% end
+
+%% create the xml file of PCO camera
+% XmlInput.Camera.CameraName='PCO';
+% t=struct2xml(XmlInput.Camera);
+% t=set(t,1,'name','ImaDoc');
+% save(t,fullfile(Param.InputTable{1,1},'PCO.xml'))
+
+%% remove initial files if transfer OK
+%     if i_index== (size(XmlInput.Time,1)-1)
+% 
+%         [SUCCESS,MESSAGE]=rmdir(DirImages,'s')
+%        
+%     end
Index: /trunk/src/transform_field/ima_color2BW.m
===================================================================
--- /trunk/src/transform_field/ima_color2BW.m	(revision 971)
+++ /trunk/src/transform_field/ima_color2BW.m	(revision 972)
@@ -30,5 +30,5 @@
 DataOut=DataIn; %default
 if ndims(DataOut.A)==3
-    DataOut.A=uint16(sum(double(DataOut.A,3)));%sum on color components, transform in 16 bit BW images
+    DataOut.A=uint16(sum(double(DataOut.A),3));%sum on color components, transform in 16 bit BW images
 end
  
Index: /trunk/src/uvmat.m
===================================================================
--- /trunk/src/uvmat.m	(revision 971)
+++ /trunk/src/uvmat.m	(revision 972)
@@ -1177,7 +1177,7 @@
     'String',num2str(SliceAngle(1)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_1_1'':first slice angle of inclination around the x axis');%edit box
 uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-5*ii-4.2*hh ww hh],'tag','num_SliceAngle_1_2','BackgroundColor',[1 1 1],...
-    'String',num2str(SliceAngle(2)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_1_2'':last slice angle of inclination around the x axis');%edit box
+    'String',num2str(SliceAngle(1)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_1_2'':last slice angle of inclination around the x axis');%edit box
 uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+2*ww 0.95-6*ii-5.2*hh ww hh],'tag','num_SliceAngle_2_1','BackgroundColor',[1 1 1],...
-    'String',num2str(SliceAngle(1)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_2_1'':first slice angle of inclination around the y axis');%edit box
+    'String',num2str(SliceAngle(2)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_2_1'':first slice angle of inclination around the y axis');%edit box
 uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-6*ii-5.2*hh ww hh],'tag','num_SliceAngle_2_2','BackgroundColor',[1 1 1],...
     'String',num2str(SliceAngle(2)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_2_2'':last slice angle of inclination around the y axis');%edit box
@@ -1269,4 +1269,6 @@
 uvmat('InputFileREFRESH_Callback',huvmat,[],hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
 set(hObject,'BackgroundColor',[1 0 0]);% paint button back to red
+
+delete(hset_slice)
 
 %------------------------------------------------------------------------
@@ -1338,6 +1340,6 @@
 function set_slice_Cancel_Callback(hObject,eventdata)
 %------------------------------------------------------------------------
-hfig=get(hObject,'parent');
-delete(hfig)
+hset_slice=get(hObject,'parent');
+delete(hset_slice)
 
 %-----------------------------------------------------------------------
