Index: trunk/src/series/aver_stat.m
===================================================================
--- trunk/src/series/aver_stat.m	(revision 577)
+++ trunk/src/series/aver_stat.m	(revision 583)
@@ -240,5 +240,5 @@
             
             %% calculate tps coefficients if needed
-            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'filter')
+            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps')
                 Field=calc_tps(Field,check_proj_tps);
             end
Index: trunk/src/series/check_peaklock.m
===================================================================
--- trunk/src/series/check_peaklock.m	(revision 583)
+++ trunk/src/series/check_peaklock.m	(revision 583)
@@ -0,0 +1,297 @@
+%%-------------------------------------------------------
+% --- Executes on button press in peaklocking. TODO: UPDATE
+%-------------------------------------------------
+function peaklocking(handles)
+%evaluation of peacklocking errors
+%use splinhist: give spline coeff cc for a smooth histo (call spline4)
+%use histsmooth(x,cc): calculate the smooth histo for any value x
+%use histder(x,cc): calculate the derivative of the smooth histo
+global hfig1 hfig2 hfig3
+global nbb Uval Vval Uhist Vhist % nbb resolution of the histogram nbb=10: 10 values in unity interval
+global xval xerror yval yerror
+
+set(handles.vector_y,'Value',1)% trigger the option Uhist on the interface
+set(handles.Vhist_input,'Value',1)
+set(handles.cm_switch,'Value',0) % put the switch to 'pixel'
+
+%adjust the extremal values of the histogram in U with respect to integer
+%values
+minimU=round(min(Uval)-0.5)+0.5; %first value of the histogram with integer bins 
+maximU=round(max(Uval)-0.5)+0.5;
+minim_fin=(minimU-0.5+1/(2*nbb)); % first bin valueat the beginning of an integer interval
+maxim_fin=(maximU+0.5-1/(2*nbb)); % last integer value
+nb_bin_min= round(-(minim_fin - min(Uval))*nbb); % nbre of bins added below
+nb_bin_max=round((maxim_fin -max(Uval))*nbb); %nbre of bins added above
+Uval=[minim_fin:(1/nbb):maxim_fin];
+histu_min=zeros(nb_bin_min,1);
+histu_max=zeros(nb_bin_max,1);
+Uhist=[histu_min; Uhist ;histu_max]; % column vector
+
+%adjust the extremal values of the histogram in V
+minimV=round(min(Vval-0.5)+0.5);
+maximV=round(max(Vval-0.5)+0.5);
+minim_fin=minimV-0.5+1/(2*nbb); % first bin valueat the beginning of an integer interval
+maxim_fin=maximV+0.5-1/(2*nbb); % last integer value
+nb_bin_min=round((min(Vval) - minim_fin)*nbb); % nbre of bins added below
+nb_bin_max=round((maxim_fin -max(Vval))*nbb);
+Vval=[minim_fin:(1/nbb):maxim_fin];
+histu_min=zeros(nb_bin_min,1);
+histu_max=zeros(nb_bin_max,1);
+Vhist=[histu_min; Vhist ;histu_max]; % column vector
+
+% RUN_histo_Callback(hObject, eventdata, handles)
+% %adjust the histogram to integer values:
+
+%histoU and V
+[Uhistinter,xval,xerror]=peaklock(nbb,minimU,maximU,Uhist);
+[Vhistinter,yval,yerror]=peaklock(nbb,minimV,maximV,Vhist);
+
+% selection of value ranges such that histo>=10 (enough statistics)
+Uval_ind=find(Uhist>=10);
+ind_min=min(Uval_ind);
+ind_max=max(Uval_ind);
+U_min=Uval(ind_min);% minimum allowed value 
+U_max=Uval(ind_max);%maximum allowed value
+
+% selection of value ranges such that histo>=10 (enough statistics)
+Vval_ind=find(Vhist>=10);
+ind_min=min(Vval_ind);
+ind_max=max(Vval_ind);
+V_min=Vval(ind_min);% minimum allowed value 
+V_max=Vval(ind_max);%maximum allowed value
+
+figure(4)% plot U histogram with smoothed one
+plot(Uval,Uhist,'b')
+grid on
+hold on
+plot(Uval,Uhistinter,'r');
+hold off
+
+figure(5)% plot V histogram with smoothed one
+plot(Vval,Vhist,'b')
+grid on
+hold on
+plot(Vval,Vhistinter,'r');
+hold off
+
+figure(6)% plot pixel error in two subplots
+hfig4=subplot(2,1,1);
+hfig5=subplot(2,1,2);
+axes(hfig4)
+plot(xval,xerror)
+axis([U_min U_max -0.4 0.4])
+xlabel('velocity u (pix)')
+ylabel('peaklocking error (pix)')
+grid on
+axes(hfig5)
+plot(yval,yerror)
+axis([V_min V_max -0.4 0.4]);
+xlabel('velocity v (pix)')
+ylabel('peaklocking error (pix)')
+grid on
+
+
+
+
+
+
+
+
+
+%'peaklock': determines peacklocking errors from velocity histograms.
+%-------------------------------------------------------
+%first smooth the input histogram 'histu' in such a way that the integral over
+%n-n+1 is preserved, then deduce the peaklocking 'error' function of the pixcel displacement 'x'.
+%
+% [histinter,x,error]=peaklock(nbb,minim,maxim,histu)
+%OUTPUT:
+%histinter: smoothed interpolated histogram
+% x: vector of displacement values.
+% error: vector of estimated errors corresponding to x
+%INPUT:
+%histu=vector representing the values of histogram  of measured velocity ;
+%minim, maxim: extremal values of the measured velocity (absica for histu)
+%nbb: number of bins inside each integer interval for the histograms
+%SUBROUTINES INCLUDED:
+%spline4.m% spline interpolation at 4th order
+%splinhist.m: give spline coeff cc for a smooth histo (call spline4)
+%histsmooth.m(x,cc): calculate the smooth histo for any value x
+%histder.m(x,cc): calculate the derivative of the smooth histo
+function [histinter,x,error]=peaklock(nbb,minim,maxim,histu)
+
+nint=maxim-minim+1
+xfin=[minim-0.5+1/(2*nbb):(1/nbb):maxim+0.5-(1/(2*nbb))];
+histo=(reshape(histu,nbb,nint));%extract values with x between integer -1/2 integer +1/2
+Integ=sum(histo)/nbb; %integral of the pdf on each integer bin
+[histinter,cc]=splinhist(Integ,minim,nbb);
+histx=reshape(histinter,nbb,nint);
+xint=[minim:1:maxim];
+x=zeros(nbb,nint);
+%determination of the displacement x(j,:)
+%j=1
+delx=histo(1,:)./histsmooth(-0.5*ones(1,nint),cc)/nbb;
+%del(1,:)=delx;
+x(1,:)=-0.5+delx-(delx.*delx/2).*histder(-0.5*ones(1,nint),cc);
+%histx(1,:)=histsmooth(x(j-1,:),cc);
+for j=2:nbb
+    delx=histo(j,:)./histsmooth(x(j-1,:),cc)/nbb;
+    %delx=delx.*(delx<3*ones(1,nint)/nbb)+3*ones(1,nint)/nbb.*~(delx <3*ones(1,nint)/nbb)
+    x(j,:)=x(j-1,:)+delx-(delx.*delx/2).*histder(x(j-1,:),cc);
+end
+%reshape
+xint=ones(nbb,1)*xint;
+x=x+xint;
+x=reshape(x,1,nbb*nint);
+error=xfin+1/(2*nbb)-x;
+
+%-------------------------------------------------------
+% --- determine the spline coefficients cc for the interpolated histogram.
+%-------------------------------------------------
+function [histsmooth,cc]= splinhist(Integ,mini,nbb)
+% provides a smooth histogramm histmooth, which remains always positive,
+% and is such that its sum over each integer bin [i-1/2 i+1/2] is equal to
+% Integ(i). The function determines histmooth as the exponential of a 4th
+% order spline function and adjust the cefficients by a Newton method to
+% fit the integral conditions Integ
+% histmooth is determined at the abscissa
+% xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))] (maxi=mini+size(aa)-1)
+%cc(1-5,i) provides the spline coefficients
+
+% order 0
+siz=size(Integ);
+nint=siz(2);
+izero=find(Integ==0); %indices of zero elements
+inonzero=find(Integ);
+Integ(izero)=min(Integ(inonzero));
+aa=log(Integ);%initial guess for a coeff
+spli=spline4(aa,mini,nbb);  %appel à la fonction spline4
+histsmooth=exp(spli);
+
+S=(sum(reshape(histsmooth,nbb,nint)))/nbb;% integral of the fit histsmooth on ]i-1/2 i+1/2[
+epsilon=max(abs(Integ-S));
+iter=0;
+while epsilon > 0.000001 & iter<10
+ident=eye(nint);
+dSda=ones(nint);
+for j=1:nint% determination of the jacobian matrix dSda
+dhistda=spline4(ident(j,:),mini,nbb);
+expdhistda=dhistda.*histsmooth;
+dSda(j,:)=(sum(reshape(expdhistda,nbb,nint)))/nbb;
+end
+aa=aa+(Integ-S)*inv(dSda);%new estimate of coefficients aa by linear interpolation
+[spli,bb]=spline4(aa,mini,nbb);% new fit histsmooth
+histsmooth=exp(spli);
+S=(sum(reshape(histsmooth,nbb,nint)))/nbb;% integral of the fit histsmooth on ]i-1/2 i+1/2[
+epsilon=max(abs(Integ-S));
+iter=iter+1;
+end
+if iter==10, errordlg('splinhist did not converge after 10 iterations'),end
+cc(1,:)=aa;
+cc(2,:)=bb(1,:);
+cc(3,:)=bb(2,:);
+cc(4,:)=bb(3,:);
+cc(5,:)=bb(4,:);
+
+%-------------------------------------------------------
+% --- determine the 4th order spline coefficients from the function values aa.
+%-------------------------------------------------
+function [histsmooth,bb]= spline4(aa,mini,n)
+% spline interpolation at 4th order
+%aa=vector of values of a function at integer abscissa, starting at mini
+%n=number of subdivisions for the interpolated function
+% histmooth =interpolated values at absissa
+% xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))] (maxi=mini+size(aa)-1)
+%bb=[b(i);c(i);d(i); e(i)] matrix of spline coeff
+L1=[1/2 1/4 1/8 1/16;1 1 3/4 1/2;0 2 3 3;0 0 6 12];
+L2=[-1/2 1/4 -1/8 1/16;1 -1 3/4 -1/2;0 2 -3 3;0 0 6 -12];
+M=inv(L2)*L1;
+[V,D]=eig(M);
+F=-inv(V)*inv(L2)*[1 ;0 ;0;0];
+a1rev=[1 -1/D(1,1)];
+b1rev=[F(1)/D(1,1)];
+a2rev=[1 -1/D(2,2)];
+b2rev=[F(2)/D(2,2)];
+a3=[1 -D(3,3)];
+b3=[F(3)];
+a4=[1 -D(4,4)];
+b4=[F(4)];
+
+%data
+% n=10;% résolution de la pdf: nbre de points par unite de u
+% mini=-10.0;%general mini=uint16(min(values)-1 CHOOSE maxi-mini+1 EVEN
+% maxi=9.0; % general maxi=uint16(max(values))+1
+%nint=double(maxi-mini+1); % nombre d'intervals entiers EVEN!
+siz=size(aa);
+nint=siz(2);
+maxi=mini+nint-1;
+npdf=nint*n;% nbre total d'intervals à introduire dans la pdf: hist(u,npdf)
+%simulation de pdf
+xfin=[mini-0.5+1/(2*n):(1/n):maxi+0.5-(1/(2*n))];% valeurs d'interpolation: we take n values in each integer interval
+%histolin=exp(-(xfin-1).*(xfin-1)).*(2+cos(10*(xfin-1)));% simulation d'une pdf
+%histo=log(histolin);
+%histo=sin(2*pi*xfin);
+%histextract=(reshape(histo,n,nint));
+%aa=sum(histextract)/n %integral of the pdf on each integer bin
+IP=[0 diff(aa)];
+Irev=zeros(size(aa));
+for i=1:nint
+    Irev(i)=aa(end-i+1);
+end
+IPrev=[0 diff(Irev)];
+
+%get the spline coelfficients a_d, using filter on the eigen vectors A,B,C
+Arev=filter(b1rev,a1rev,IPrev);
+Brev=filter(b2rev,a2rev,IPrev);
+C=filter(b3,a3,IP);
+D=filter(b4,a4,IP);
+A=zeros(size(Arev));
+B=zeros(size(Brev));
+for i=1:nint
+    A(i)=Arev(end-i+1);
+    B(i)=Brev(end-i+1);
+end
+%Matr=V*[A;B;C;D];
+bb=V*[A;B;C;D];
+%b=Matr(1,:);
+%c=Matr(2,:);
+%d=Matr(3,:);
+%e=Matr(4,:);
+%a=aa;
+
+%calculate the interpolation using the spline coefficients a-d
+%xextract=(reshape(xfin,n,nint));% 
+chi=xfin+1/(2*n)-min(xfin)-double(int16(xfin+(1/(2*n))-min(xfin)))-0.5;% decimal part
+chi2=chi.*chi;
+chi3=chi2.*chi;
+chi4=chi3.*chi;
+avec=reshape(ones(n,1)*aa,1,n*nint);
+bvec=reshape(ones(n,1)*bb(1,:),1,n*nint);
+cvec=reshape(ones(n,1)*bb(2,:),1,n*nint);
+dvec=reshape(ones(n,1)*bb(3,:),1,n*nint);
+evec=reshape(ones(n,1)*bb(4,:),1,n*nint);
+histsmooth=avec+bvec.*chi+cvec.*chi2+dvec.*chi3+evec.*chi4;
+
+%-------------------------------------------------------
+% --- determine the interpolated histogram at points chi from the spline ceff cc.
+%-------------------------------------------------
+function histx= histsmooth(chi,cc)
+% provides the value of the interpolated histogram at values chi=x-i
+%(difference with the mnearest integer)
+% cc(5,size(chi)) is the set of spline coefficients obtained by splinhist
+chi2=chi.*chi;
+chi3=chi2.*chi;
+chi4=chi3.*chi;
+histx=exp(cc(1,:)+cc(2,:).*chi+cc(3,:).*chi2+cc(4,:).*chi3+cc(5,:).*chi4);
+
+%-------------------------------------------------------
+% --- determine the derivative p'/p of the interpolated histogram at points chi from the spline ceff cc.
+%-------------------------------------------------
+function histder= histder(chi,cc)
+% provides the logarithmique derivative p'/p of the interpolated histogram
+%at values chi=x-i
+%(difference with the nearest integer)
+% cc(5,size(chi)) is the set of spline coefficients obtained by splinhist
+chi2=chi.*chi;
+chi3=chi2.*chi;
+chi4=chi3.*chi;
+histder=cc(2,:)+2*cc(3,:).*chi+3*cc(4,:).*chi2+4*cc(5,:).*chi3;
Index: trunk/src/series/sub_field_series.m
===================================================================
--- trunk/src/series/sub_field_series.m	(revision 577)
+++ 	(revision )
@@ -1,400 +1,0 @@
-%'sub_field_series': substract the two input field series, then possibly project them on a grid (like merge_proj;m)
-% GUI_input=sub_field_series(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
-%
-function GUI_input=sub_field_series(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={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
-        'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
-        'RootFile';'on';... %root input file name ('on' by default)
-        'FileExt';'on';... %input file extension ('on' by default)
-        'NomType';'on';...%type of file indexing ('on' by default)
-        'NbSlice';'on'; ...%nbre of slices ('off' by default)
-        'VelTypeMenu';'one';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default)
-        'FieldMenu';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
-        'CoordType';'on';...%can use a transform function 'off' by default
-   %     'GetObject';'on';...%can use projection object ,'off' by default
-        %'GetMask';'on'...%can use mask option   ,'off' by default
-        %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter 
-               ''};
-    return %exit the function 
-end
-
-%-------------------------------------------------
-hseries=guidata(Series.hseries);%handles of the GUI series
-WaitbarPos=get(hseries.waitbar_frame,'Position'); %positiopn of waitbar frame
-%-------------------------------------------------
-
-
-%% numbers of view fields (nbre of inputs in RootPath)
-testcell=iscell(Series.RootFile);
-if ~testcell
-    Series.RootPath={Series.RootPath};
-    Series.RootFile={Series.RootFile};
-    Series.SubDir={Series.SubDir};
-    Series.FileExt={Series.FileExt};
-    Series.NomType={Series.NomType};
-    num_i1={num_i1};
-    num_i2={num_i2};
-    num_j1={num_j1};
-    num_j2={num_j2};
-end 
-nbview=length(Series.RootFile);%number of views (file series to merge)
-nbfield=size(num_i1{1},1)*size(num_i1{1},2);%number of fields in the time series
-hhh=which('mmreader');
-for iview=1:nbview
-    test_movie(iview)=0;
-    if ~isequal(hhh,'')&& mmreader.isPlatformSupported()
-        if isequal(lower(Series.FileExt{iview}),'.avi')
-            MovieObject{iview}=mmreader(fullfile(Series.RootPath{iview},[Series.RootFile{iview} Series.FileExt{iview}]));
-            test_movie(iview)=1;
-        end
-    end 
-end
-
-%% Calibration data and timing: read the ImaDoc files
-timecell={};
-itime=0;
-NbSlice_calib={}; %test for z index 
-for iview=1:nbview%Loop on views (nbview=2)
-    XmlData{iview}=[];%default
-    filebase{iview}=fullfile(Series.RootPath{iview},Series.RootFile{iview});
-    testxml(iview)=0;% test for xml file
-    if exist([filebase{iview} '.xml'],'file')
-        testxml(iview)=1;
-        [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); 
-        if isfield(XmlData{iview},'Time')
-            itime=itime+1;
-            timecell{itime}=XmlData{iview}.Time;
-        end
-        if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')
-            NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);
-            if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
-                msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
-            end
-        end    
-    elseif exist([filebase{iview} '.civ'],'file')
-        [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']);
-        itime=itime+1;
-        timecell{itime}=time;
-        XmlData{iview}.Time=time;
-        GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
-        GeometryCalib.Tx=0;
-        GeometryCalib.Ty=0;
-        GeometryCalib.Tz=1;
-        GeometryCalib.dpx=1;
-        GeometryCalib.dpy=1;
-        GeometryCalib.sx=1;
-        GeometryCalib.Cx=0;
-        GeometryCalib.Cy=0;
-        GeometryCalib.f=1;
-        GeometryCalib.kappa1=0;
-        GeometryCalib.CoordUnit='cm';
-        XmlData{iview}.GeometryCalib=GeometryCalib;
-        if error==1
-            msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file');
-        end
-    end
-end
-
-%% check coincidence in time
-multitime=0;
-if isempty(timecell)
-    time=[];
-elseif length(timecell)==1
-    time=timecell{1};
-elseif length(timecell)>1
-    multitime=1;
-    for icell=1:length(timecell)
-        if ~isequal(size(timecell{icell}),size(timecell{1}))
-            msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
-            time=timecell{1};
-            multitime=0;
-            break
-        end
-    end
-end
-if multitime
-    for icell=1:length(timecell)
-        time(icell,:,:)=timecell{icell};
-    end
-    diff_time=max(max(diff(time)));
-    if diff_time>0
-        msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)])
-    end   
-end
-if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file' 
-    time=[];
-end
-
-%% coordinate transform or other user defined transform
-transform_fct=[];%default
-if isfield(Series,'transform_fct')
-    transform_fct=Series.transform_fct;
-end
-
-%% Field and velocity type (the same for all views)
-FieldName='';
-if strcmp(get(hseries.FieldMenu,'Visible'),'on')
-    Field_str=get(hseries.FieldMenu,'String');
-    val=get(hseries.FieldMenu,'Value');
-    FieldName=Field_str(val);%the same set of fields for all views
-    VelType_str=get(hseries.VelTypeMenu,'String');
-    VelType_val=get(hseries.VelTypeMenu,'Value');
-    VelType=VelType_str{VelType_val}; %the same for all views
-    if strcmp(FieldName,'')
-        msgbox_uvmat('ERROR','no input field defined in FieldMenu')
-    elseif strcmp(FieldName,'get_field...')
-        hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
-        SubField=get_field('read_get_field',hObject,eventdata,hget_field); %read the names of the variables to plot in the get_field GUI
-    end
-end
-%detect whether all the files are 'images' or 'netcdf'
-testima=0;
-testvol=0;
-testcivx=0;
-testnc=0;
-FileExt=get(hseries.FileExt,'String');
-for iview=1:nbview
-     ext=FileExt{iview};
-     form=imformats(ext(2:end));
-     if isequal(lower(ext),'.vol')
-         testvol=testvol+1;
-     elseif ~isempty(form)||isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab
-         testima=testima+1;
-     elseif isequal(ext,'.nc')
-         testnc=testnc+1;
-     end
-end
-if testvol
-    msgbox_uvmat('ERROR','volume images not implemented yet')
-    return
-end
-if testnc~=nbview && testima~=nbview && testvol~=nbview
-    msgbox_uvmat('ERROR','need a set of images or a set of netcdf files with the same fields as input')
-    return
-end
-if ~isequal(FieldName,'get_field...')
-    testcivx=testnc;
-end
-if nbview~=2
-    msgbox_uvmat('ERROR','this function needs two input series as input')
-    return
-elseif testima
-    answer=msgbox_uvmat('CONFIRMATION','this function will substract each of the second image series from the first one');
-    if ~isequal(answer,'Yes')
-        return
-    end
-else
-    answer=msgbox_uvmat('CONFIRMATION','this function will substract each the second field series from the first one');
-    if ~isequal(answer,'Yes')
-        return
-    end
-end
-
-
-%% name of output files and directory:
-ProjectDir=fileparts(fileparts(Series.RootPath{1}));% preoject directory (GERK)
-prompt={['result directory (in' ProjectDir ')']};
-RootPath=get(hseries.RootPath,'String');
-SubDir=get(hseries.SubDir,'String');
-def={fullfile(ProjectDir,'0_RESULTS')};
-dlgTitle='result directory';
-lineNo=1;
-answer=msgbox_uvmat('INPUT_TXT',dlgTitle,def);
-fulldir=answer{1};
-subdir=[];
-dirlist=sort(Series.RootFile);
-for iview=1:nbview
-    if ~isempty(subdir)
-        subdir=[subdir '-'];
-    end
-    subdir=[subdir dirlist{iview}];
-end  
-res_subdir=fullfile(fulldir,subdir);
-
-ext=FileExt{1};
-if ~exist(fulldir,'dir')
-    msgbox_uvmat('ERROR',['directory ' fulldir ' needs to be created'])
-    return
-end
-if ~exist(res_subdir,'dir')
-    dircur=pwd;
-    cd(fulldir);
-    succeed=mkdir(subdir);
-    if succeed
-        [xx,msg2] = fileattrib(res_subdir,'+w','g'); %yield writing access (+w) to user group (g)
-        if ~strcmp(msg2,'')
-            msgbox_uvmat('ERROR',['pb of permission for ' res_subdir ': ' msg2])%error message for directory creation
-            cd(dircur)
-            return
-        end
-        cd(dircur);
-    else
-        msgbox_uvmat('ERROR',['Cannot create directory ' fulldir])
-        return
-    end
-end
-filebasesub=fullfile(res_subdir,Series.RootFile{1});
-filebase_merge=fullfile(res_subdir,'sub');%root name for the merged files
- if testxml(1) && ( isempty(transform_fct)|| isequal(transform_fct,'px'))
-        copyfile([filebase{1} '.xml'],[filebase_merge '.xml'])% reproduce the xml file
-        display([filebase_merge '.xml copied from ' filebase{1} '.xml'])
-    end
-
-%% MAIN LOOP
-for ifile=1:nbfield                
-    stopstate=get(hseries.RUN,'BusyAction');
-    if isequal(stopstate,'queue')% enable STOP command from the 'series' interface
-         update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield)
-         
-        %% ----------LOOP ON VIEWS----------------------
-        nbtime=0;
-        for iview=1:nbview
-         %name of the current file
-            filename=name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview});
-            if ~exist(filename,'file')
-                msgbox_uvmat('ERROR',['missing input file' filename])
-                break
-            end
-         %reading the current file
-            if testima
-                if test_movie(iview)
-                    Field{iview}.A=read(MovieObject{iview},num_i1{iview}(ifile));
-                else
-                    Field{iview}.A=imread(filename); 
-                end % TODO: introduce ListVarName
-                npxy=size(Field{iview}.A);
-                Field{iview}.ListVarName={'AX','AY','A'};
-                Field{iview}.VarDimName={'AX','AY',{'AY','AX'}};
-                Field{iview}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
-                Field{iview}.AY=[npxy(1)-0.5 0.5];
-                Field{iview}.CoordUnit='pixel'; 
-                Field{iview}.AName='image';
-                timeread(iview)=0;
-            else
-                if testcivx
-                    [Field{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType);
-                else
-                    [Field{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data                
-                    Field{iview}.VarAttribute=SubField.VarAttribute;
-                end
-                if isfield(Field{iview},'Txt')
-                    msgbox_uvmat('ERROR',Field{iview}.Txt)
-                    return
-                end
-                if isfield(Field{iview},'Time')
-                    timeread(iview)=Field{iview}.Time;
-                    nbtime=nbtime+1;
-                end
-            end
-            if ~isempty(NbSlice_calib)
-                Field{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;
-            end
-         %transform the input field (e.g; phys) if requested
-            if ~isempty(transform_fct)
-                Field{iview}=transform_fct(Field{iview},XmlData{iview});  %transform to phys if requested
-            end
-            if testcivx
-                Field{iview}=calc_field(FieldName,Field{iview});
-            end
-         %projection on object (gridded plane)
-%             if test_object
-%                 Field{iview}=proj_field(Field{iview},ProjObject);
-%             end
-        end    
-        %----------END LOOP ON VIEWS----------------------
-         
-        %% merge the nbview=2 fields
-        MergeData=sub_field(Field{1},Field{2});
-        if isfield(MergeData,'Txt')
-            msgbox_uvmat('ERROR',MergeData.Txt)
-            return
-        end        
-        
-     % time of the merged field:
-        time_i=0;%default
-        if isempty(time)% time from ImaDoc prevails
-            time_i=sum(timeread)/nbtime;
-        else
-            time_i=(time(iview,num_i1{iview}(ifile),num_j1{iview}(ifile))+time(iview,num_i2{iview}(ifile),num_j2{iview}(ifile)))/2;
-        end
-        
-     % recording the merged field
-        if testima    %in case of input images an image is produced 
-             % generating the name of the merged field
-            mergename=name_generator(filebase_merge,num_i1{1}(ifile),num_j1{1}(ifile),'.png',Series.NomType{1},1,num_i2{1}(ifile),num_j2{1}(ifile));
-             if isa(Field{1}.A,'uint8')
-                imwrite(uint8(MergeData.A),mergename,'BitDepth',8); % transform in integers (and put to 0 the negative values)
-             elseif isa(Field{1}.A,'uint16')
-                 imwrite(uint16(MergeData.A),mergename,'BitDepth',16);
-             end
-             display(['output image ' mergename ' written'])
-        else
-            mergename=name_generator(filebase_merge,num_i1{1}(ifile),num_j1{1}(ifile),'.nc',Series.NomType{1},1,num_i2{1}(ifile),num_j2{1}(ifile));
-            MergeData.ListGlobalAttribute={'Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'};        
-            MergeData.nb_coord=2;
-            MergeData.nb_dim=2;
-            dt=[];
-            if isfield(Field{1},'dt')&& isnumeric(Field{1}.dt)
-                dt=Field{1}.dt;
-            end
-            for iview =2:numel(Field)
-                if ~(isfield(Field{iview},'dt')&& isequal(Field{iview}.dt,dt))
-                    dt=[];%dt not the same for all fields
-                end
-            end
-            if isempty(dt)
-                MergeData.ListGlobalAttribute(6)=[];
-            else
-               MergeData.dt=dt;
-            end
-            MergeData.Time=time_i;
-            error=struct2nc(mergename,MergeData);%save result file
-            if isempty(error)
-                display(['output file ' mergename ' written'])
-            else
-                display(error)
-            end
-        end
-    end
-end
-%write xml calibration file
-if testima && ~isempty(transform_fct) && ~isequal(transform_fct,'px')
-    siz=size(MergeData.A);
-    npy=siz(1);
-    npx=siz(2);
-    if isfield(MergeData,'VarAttribute')&&isfield(MergeData.VarAttribute{1},'Coord_2')&&isfield(MergeData.VarAttribute{1},'Coord_1')
-        Rangx=MergeData.VarAttribute{1}.Coord_2;
-        Rangy=MergeData.VarAttribute{1}.Coord_1;
-    elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY')
-        Rangx=[MergeData.AX(1) MergeData.AX(end)];
-        Rangy=[MergeData.AY(1) MergeData.AY(end)];
-    else
-        Rangx=[0.5 npx-0.5];
-        Rangy=[npy-0.5 0.5];%default
-    end
-    pxcmx=(npx-1)/(Rangx(2)-Rangx(1));
-    pxcmy=(npy-1)/(Rangy(1)-Rangy(2));
-    T_x=-pxcmx*Rangx(1)+0.5;
-    T_y=-pxcmy*Rangy(2)+0.5;
-    GeometryCal.focal=1;
-    GeometryCal.R=[pxcmx,0,0;0,pxcmy,0;0,0,1];
-    GeometryCal.Tx_Ty_Tz=[T_x T_y 1];
-    ImaDoc.GeometryCalib=GeometryCal;
-    t=struct2xml(ImaDoc);
-    t=set(t,1,'name','ImaDoc');
-    save(t,[filebase_merge '.xml'])
-    display([filebase_merge '.xml saved'])
-end
Index: trunk/src/series/time_series.m
===================================================================
--- trunk/src/series/time_series.m	(revision 577)
+++ trunk/src/series/time_series.m	(revision 583)
@@ -267,5 +267,5 @@
             
             % calculate tps coefficients if needed
-            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'filter')
+            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps')
                 Field=calc_tps(Field,check_proj_tps);
             end
