Index: trunk/src/plot_object.m
===================================================================
--- trunk/src/plot_object.m	(revision 1098)
+++ trunk/src/plot_object.m	(revision 1099)
@@ -245,5 +245,6 @@
     end
 end
-if ismember(ObjectData.Type,{'line','polyline','polygon'})
+if ismember(ObjectData.Type,{'line','polyline','polygon'})&&...
+        ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
     if length(xline)<2
         theta=0;
@@ -357,11 +358,19 @@
                 end
             elseif length(PlotData.SubObject)==2
-                set(PlotData.SubObject(1),'XData',xinf);
-                set(PlotData.SubObject(1),'YData',yinf);
-                set(PlotData.SubObject(2),'XData',xsup);
-                set(PlotData.SubObject(2),'YData',ysup);
+                if ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
+                    set(PlotData.SubObject(1),'XData',xinf);
+                    set(PlotData.SubObject(1),'YData',yinf);
+                    set(PlotData.SubObject(2),'XData',xsup);
+                    set(PlotData.SubObject(2),'YData',ysup);
+                end
             elseif length(PlotData.SubObject)==1
-                set(PlotData.SubObject(1),'XData',xsup);
-                set(PlotData.SubObject(1),'YData',ysup);
+                if ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
+                    set(PlotData.SubObject(1),'XData',xsup);
+                    set(PlotData.SubObject(1),'YData',ysup);
+                end
+            end
+            if strcmp(ObjectData.ProjMode,'none')
+                delete(PlotData.SubObject)
+                PlotData=rmfield(PlotData,'SubObject');
             end
         end
@@ -398,12 +407,7 @@
     end
     if test_patch
+        createimage=1;
         if isfield(PlotData,'SubObject')
-        for iobj=1:length(PlotData.SubObject)
-            if ~ishandle(PlotData.SubObject(iobj))
-                hold on
-                hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
-                set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
-                PlotData.SubObject(iobj)=hhh;
-            else
+            for iobj=1:length(PlotData.SubObject)
                 objtype=get(PlotData.SubObject(iobj),'Type');
                 if isequal(objtype,'image')
@@ -411,7 +415,13 @@
                     set(PlotData.SubObject(iobj),'XData',[xlim(1)+dx/2 xlim(2)-dx/2])
                     set(PlotData.SubObject(iobj),'YData',[ylim(1)+dy/2 ylim(2)-dy/2])
-                end
-            end
-        end 
+                    createimage=0;
+                end
+            end
+        end
+        if createimage
+            hold on
+            hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
+            set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
+            PlotData.SubObject(1)=hhh;
         end
     else% no patch image requested, erase existing ones
@@ -420,4 +430,5 @@
                 if ishandle(PlotData.SubObject(iobj)) && strcmp(get(PlotData.SubObject(iobj),'Type'),'image')
                     delete(PlotData.SubObject(iobj))
+                    PlotData=rmfield(PlotData,SubObject(iobj));
                 end
             end
@@ -462,6 +473,8 @@
         case {'line','polyline','polygon'}
             hh=line(xline,yline,'Color',col);
+            if ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
                 PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
                 PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
+            end
                 for ipt=1:sizcoord(1)
                     PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
@@ -496,3 +509,8 @@
     end
 end
+%put the deformpoints to the front
+            listc=get(gca,'children');
+            checkdeform=strcmp(get(listc,'tag'),'DeformPoint');
+            [nn,Index]=sort(checkdeform,'descend');
+            set(gca,'children',listc(Index))
 set(hh,'UserData',PlotData)
Index: trunk/src/series/extract_multitif.m
===================================================================
--- trunk/src/series/extract_multitif.m	(revision 1098)
+++ trunk/src/series/extract_multitif.m	(revision 1099)
@@ -1,7 +1,6 @@
-%'ima2netcdf': read image series and transform to netcdf
+%'extract_multitif': read image series from PCO cameras (tiff image series) and write .png images
 %------------------------------------------------------------------------
-
     
-% function ParamOut=ima2netcdf(Param)
+% function ParamOut=extract_multitif(Param)
 %
 %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -59,5 +58,5 @@
 %=======================================================================
 
-function ParamOut=extract_multitif_parallel(Param)
+function ParamOut=extract_multitif(Param)
 
 %%%%%%%%%%%%%%%%%    INPUT PREPARATION MODE (no RUN)    %%%%%%%%%%%%%%%%%
@@ -74,5 +73,5 @@
     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)
-    ParamOut.CPUTime=7;% expected time for writting one image ( in minute)
+    ParamOut.CPUTime=10;% expected time for writting the output of one source image ( in minute)
     %% root input file(s) and type
     % check the existence of the first file in the series
@@ -126,13 +125,34 @@
 ImagesPerLevel=size(XmlInput.Time,2)-1;%100;%use the xmlinformation to get the nbre of j indices
 
-%% create the xml file of PCO camera if it does not exist
-Newxml=fullfile(Param.InputTable{1,1},[Param.InputTable{1,2} '.xml']);
-if ~exist(Newxml,'file')
-XmlInput.Camera.CameraName='PCO';
-XmlInput=rmfield(XmlInput,'Time');
-XmlInput=rmfield(XmlInput,'TimeUnit');
-t=struct2xml(XmlInput);
-t=set(t,1,'name','ImaDoc');
-save(t,Newxml);
+%% create the xml file for timing if it does not exist : example to adapt
+TEST=0;
+if TEST
+    count0=14;
+    Dtj=0.05;% time interval between frames
+    ImagesPerLevel=455;% total number of images per position, ImagesPerLevel-Nbj images skiiped during motion between two positions
+    Nbj=390; %Nbre of images kept at a given position
+    Dti=Dtj*ImagesPerLevel;
+    NbLevel=11;
+    NbScan=3;
+    TimeReturn=268.5; %time needed to return back to the first position (in sec)
+    NbReturn=round(TimeReturn/Dtj);
+    NbSkipReturn=NbReturn+1-NbLevel*ImagesPerLevel;
+    
+    Newxml=fullfile(Param.InputTable{1,1},[Param.InputTable{1,2} '.xml']);
+    if ~exist(Newxml,'file')
+        XmlInput.Camera.CameraName='PCO';
+        XmlInput.Camera.TimeUnit='s';
+        XmlInput.Camera.BurstTiming.FrameFrequency=1;
+        XmlInput.Camera.BurstTiming.Time=0;% for 200
+        XmlInput.Camera.BurstTiming.Dtj=Dtj;
+        XmlInput.Camera.BurstTiming.NbDtj=Nbj-1;
+        XmlInput.Camera.BurstTiming.Dti=Dti;
+        XmlInput.Camera.BurstTiming.NbDti=NbLevel-1;
+        XmlInput.Camera.BurstTiming.Dtk=TimeReturn;
+        XmlInput.Camera.BurstTiming.NbDtk=NbScan-1;
+        t=struct2xml(XmlInput);
+        t=set(t,1,'name','ImaDoc');
+        save(t,Newxml);
+    end
 end
 
Index: trunk/src/series/extract_multitif_special.m
===================================================================
--- trunk/src/series/extract_multitif_special.m	(revision 1098)
+++ 	(revision )
@@ -1,246 +1,0 @@
-%'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-2021, 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=extract_multitif_parallel(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
-    %ParamOut.ActionInput.XmlFile=uigetfile_uvmat('pick xml file for timing',fileparts(fileparts(FirstFileName)),'.xml');  
-    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]);
-OutputDirScan=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);
-%% Timing
-% XmlInputFile=Param.ActionInput.XmlFile;
-% [XmlInput,errormsg]=imadoc2struct(XmlInputFile,'Camera');
-% if ~isempty(errormsg)
-%     disp(['bad xml input file: ' errormsg])
-%     return
-% end
-%ImagesPerLevel=size(XmlInput.Time,2)-1;%100;%use the xmlinformation to get the nbre of j indices
-count0=14;
-Dtj=0.05;% time interval between frames
-ImagesPerLevel=455;% total number of images per position, ImagesPerLevel-Nbj images skiiped during motion between two positions
-Nbj=390; %Nbre of images kept at a given position
-Dti=Dtj*ImagesPerLevel;
-NbLevel=11;
-NbScan=3;
-TimeReturn=268.5; %time needed to return back to the first position (in sec)
-NbReturn=round(TimeReturn/Dtj);
-NbSkipReturn=NbReturn+1-NbLevel*ImagesPerLevel;
-%% create the xml file of PCO camera if it does not exist
-Newxml=fullfile(Param.InputTable{1,1},[Param.InputTable{1,2} '.xml']);
-if ~exist(Newxml,'file')
-    XmlInput.Camera.CameraName='PCO';
-    XmlInput.Camera.TimeUnit='s';
-    XmlInput.Camera.BurstTiming.FrameFrequency=1;
-   % XmlInput.Camera.BurstTiming.Time=-1;% for 180
-   XmlInput.Camera.BurstTiming.Time=0;% for 200
-    XmlInput.Camera.BurstTiming.Dtj=Dtj;
-    XmlInput.Camera.BurstTiming.NbDtj=Nbj-1;
-    XmlInput.Camera.BurstTiming.Dti=Dti;
-    XmlInput.Camera.BurstTiming.NbDti=NbLevel-1;
-    XmlInput.Camera.BurstTiming.Dtk=TimeReturn;
-    XmlInput.Camera.BurstTiming.NbDtk=NbScan-1;
-    %XmlInput=rmfield(XmlInput,'Time');
-    %XmlInput=rmfield(XmlInput,'TimeUnit');
-    t=struct2xml(XmlInput);
-    t=set(t,1,'name','ImaDoc');
-    save(t,Newxml);
-end
-
-%% Main loop
-
-
-% 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
-% include the first tiff file with no index in the first iteration
-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% = frame number inside a tif multimage
-        checkkeep=1;
-        count=count+1;
-        if count<count0
-            checkkeep=0;
-        else
-            countnew=count-count0+1;         
-            if countnew<=ImagesPerLevel*NbLevel % first scan of 11 levels
-                i_index=fix((countnew-1)/ImagesPerLevel)+1;
-                j_index=mod(countnew-1,ImagesPerLevel)+1;
-            elseif countnew<=NbReturn%skip 400 images during return
-                checkkeep=0;
-            elseif countnew<=NbReturn+ImagesPerLevel*NbLevel % =5930 second scan
-                i_index=fix((countnew-NbSkipReturn)/ImagesPerLevel)+1;
-                j_index=mod(countnew-NbSkipReturn,ImagesPerLevel)+1;
-            elseif countnew<=2*NbReturn %skip images during second return, from 2763 to 3167
-                checkkeep=0;
-            elseif countnew<=2*NbReturn+ImagesPerLevel*NbLevel % =5930 third scan
-                i_index=fix((countnew-2*NbSkipReturn)/ImagesPerLevel)+1;
-                j_index=mod(countnew-2*NbSkipReturn,ImagesPerLevel)+1;
-            end
-        end
-        if checkkeep
-            if j_index>Nbj
-                OutputFile='';
-            else
-                OutputFile=fullfile(OutputDir,['img_' num2str(i_index) '_' num2str(j_index) '.png']);
-            end
-            if ~isempty(OutputFile)
-                if Param.CheckOverwrite ||~exist(OutputFile,'file')
-                    A=imread(ImageName,iframe);
-                    imwrite(A,OutputFile,'BitDepth',16);
-                    disp([OutputFile ' written'])
-                else
-                    disp([OutputFile ' already exists'])
-                end
-            end
-%         else
-%             OutputFile=fullfile(OutputDir,['img_' num2str(i_index) '_' num2str(j_index) '.png']);
-        end
-    end
-end
-
-
-
Index: trunk/src/series/ima_levels_batch.m
===================================================================
--- trunk/src/series/ima_levels_batch.m	(revision 1098)
+++ 	(revision )
@@ -1,128 +1,0 @@
-%'ima_levels': rescale the image intensity to reduce strong luminosity peaks
-%------------------------------------------------------------------------
-% function GUI_input=ima_levels(num_i1,num_i2,num_j1,num_j2,Series)
-%
-%OUTPUT
-% GUI_input=list of options in the GUI series.fig needed for the function
-%
-%INPUT:
-%num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
-%num_i2:  series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
-%num_j1:  series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
-%num_j2:  series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
-%Series: Matlab structure containing information set by the series interface% relabel_i_j: relabel an image series with two indices, according to the time matrix given by ImaDoc
-%----------------------------------------------------------------------
-
-%=======================================================================
-% Copyright 2008-2021, 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 GUI_input=ima_levels_batch(num_i1,num_i2,num_j1,num_j2,Series)
-%requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
-if ~exist('num_i1','var')
-    GUI_input={};
-    return %exit the function 
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%enable waitbar
-hseries=guidata(Series.hseries);%handles of the GUI series
-WaitbarPos=get(hseries.waitbar_frame,'Position');
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-basename=fullfile(Series.RootPath,Series.RootFile) ;
-
-%create dir of the new images
-[dir_images,namebase]=fileparts(basename);
-[path,subdir_ima]=fileparts(dir_images);
-dircur=pwd;
-cd(path);
-mkdir([subdir_ima '_levels']);
-  [xx,msg2] = fileattrib([subdir_ima '_levels'],'+w','g'); %yield writing access (+w) to user group (g)
-if ~strcmp(msg2,'')
-    msgbox_uvmat('ERROR',['pb of permission for ' subdir_ima ': ' msg2])%error message for directory creation
-    cd(dircur)
-    return
-end
-cd(dircur);
-basename_new=fullfile(path,[subdir_ima '_levels'],namebase);
-
-% read imadoc
-%[XmlData,warntext]=imadoc2struct([basename '.xml']);
-% nbfield1=size(XmlData.Time,1);
-% nbfield2=size(XmlData.Time,2);
-
-msgbox_uvmat('CONFIRMATION','apply image rescaling function levels.m ');
-
-%copy the xml file
-if exist([basename '.xml'],'file')
-    copyfile([basename '.xml'],[basename_new '.xml']);% copy the .civ file
-end
-
-%main loop
-batch_file_list={};
-nbfield=size(num_i1,2);
-nbfield2=size(num_i1,1);
-for ifile=1:nbfield
-    update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield)
-    stopstate=get(hseries.RUN,'BusyAction');
-    if isequal(stopstate,'queue') % enable STOP command
-        for jfile=1:nbfield2
-            OutputFile=name_generator(basename_new,num_i1(jfile,ifile),num_j1(jfile,ifile),'',Series.NomType);
-            filename=name_generator(basename,num_i1(jfile,ifile),num_j1(jfile,ifile),Series.FileExt,Series.NomType);
-            filename_new=name_generator(basename_new,num_i1(jfile,ifile),num_j1(jfile,ifile),'.png',Series.NomType);
-            path_series=[fileparts(which('civ')) '/series'];
-            
-            filename_bat=[OutputFile '.bat'];
-            [fid,message]=fopen(filename_bat,'w');
-            if isequal(fid,-1)
-                msgbox_uvmat('ERROR', ['creation of .bat file: ' message])
-                return
-            end
-            fprintf(fid,['/opt/matlab/R2011a/bin/matlab -nodisplay -nosplash -r "cd(''' path_series ''');'...
-                'A=imread(' filename ');C=levels(A);imwrite(C,' filename_new ');exit"']);
-            fclose(fid);
-            if isunix
-                system(['chmod +x ' filename_bat]);
-            end
-            batch_file_list{length(batch_file_list)+1}=filename_bat;
-        end
-    end
-end
-
-
-ncores=1;
-walltime_onejob=10;%seconds
-filename_joblist=fullfile(path,[subdir_ima '_levels'],'job_list.txt')
-fid=fopen(filename_joblist,'w+')
-for p=1:length(batch_file_list)
-    fprintf(fid,[batch_file_list{p} '\n']);
-end
-fclose(fid);
-oar_command=['oarsub -n ima_levels '...
-    '-l /core=' num2str(ncores) ','...
-    'walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13) ' '...
-    '-E ' regexprep(filename_joblist,'\.txt\>','.errors') ' '...
-    '-O ' regexprep(filename_joblist,'\.txt\>','.log') ' '...
-    '"oar-parexec -f ' filename_joblist ' -l ' filename_joblist '.log"'];
-filename_oarcommand=fullfile(path,[subdir_ima '_levels'],'oar_command');
-fid=fopen(filename_oarcommand,'w');
-fprintf(fid,[oar_command '\n']);
-fclose(fid);
-display(oar_command);
-eval(['! . ' filename_oarcommand])
-
-
