function [AA]=proj3dF3F1v3(cc,sc,sigf3,...
    nzf1,nzf3,sw1,sw3,ph1,ph3,wndon1,wndon3,wndend1,wndend3)
% *** F3/F1 projection out of 3D time data (t1t2t3)*** 
% Y. Matsuki, February, 2009
% Y. Matsuki, May, 2012
% usage:
% [AA]=proj3dF3F1v3(cc,sc,...
%     nzf1,sw1,ph1,wndon,wndend1)
% ========================================================
tic
    orgn1=length(cc(1,:,1));
    orgn2=length(cc(1,1,:));

    if wndon3==1
    temp1=sineb3d(cc,90,wndend3,1);
    temp2=sineb3d(sc,90,wndend3,1);
    disp('wind3 done')
    else
        temp1=cc;
        temp2=sc;
    end
    clear cc
    clear sc

    tic
    temp1=fft(temp1,nzf3,1);
    temp2=fft(temp2,nzf3,1);
    toc
    disp('FT3 done')
% compatible with nmrpipe, see jan1209.m.
    temp1=mphase3dv3(temp1,sw3,ph3,1);
    temp2=mphase3dv3(temp2,sw3,ph3,1);
    disp('phase3 done')

    
%  added, feb2509
    nr=length(sigf3(:,1));
    ntot=0;
    for n=1:nr
        nele(n)=sigf3(n,2)-sigf3(n,1)+1;
        ntot=ntot+nele(n);        
    end
    
    p=1;
    cycm1=zeros(ntot,orgn1,orgn2);
    cycm2=zeros(ntot,orgn1,orgn2);
    for m=1:nr
        cycm1(p:p+nele(m)-1,:,:)=temp1(sigf3(m,1):sigf3(m,2),:,:);
        cycm2(p:p+nele(m)-1,:,:)=temp2(sigf3(m,1):sigf3(m,2),:,:);
        p=p+nele(m);
    end

    clear temp1
    clear temp2

    temp1=cycm1;
    temp2=cycm2;
    
    
        [temp1]=rrcplx3dv3(temp1,temp2);
%         [temp3]=rrcplx3dv3(cs,ss);
    disp('swap3 done')

%%
    if wndon1==1
    temp1=sineb3d(temp1,90,wndend1,2);
%     temp2=sineb3d(temp2,90,wndend1,2);
%     temp3=sineb3d(temp3,90,wndend1,2);
%     temp4=sineb3d(temp4,90,wndend1,2);
    disp('wind1 done')
    end

    tic
    temp1=fft(temp1,nzf1,2);
%     temp2=fft(temp2,nzf1,2);
%     temp3=fft(temp3,nzf1,2);
%     temp4=fft(temp4,nzf1,2);
    toc
    disp('FT1 done')

%     temp1=mphase3dv2(temp1,sw1,ph1,2);
% %     temp2=mphase3d(temp2,sw1,ph1,2);
%     temp3=mphase3dv2(temp3,sw1,ph1,2);
%     temp4=mphase3d(temp4,sw1,ph1,2);

% compatible with nmrpipe, see jan1209.m.
    temp1=mphase3dv3(temp1,sw1,ph1,2);
%     temp3=mphase3dv3(temp3,sw1,ph1,2);
    disp('phase1 done')
%     % 0.13sec x 4, wehn nt1=16
%     % 1.7sec x 4, wehn nt1=64
%     % 30sec x 4, when nt1=128
    
% %     [temp1,temp2,temp3,temp4]=rrcplx3d(temp1,temp3,temp2,temp4);
%     [temp1]=rrcplx3dv2(temp1,temp3);
% %     [temp3,temp4]=rrcplx3dv2(temp2,temp4);
%     disp('swap1 done')
%     % 17sec
% 
%     if wndon==1
%     temp1=sineb3d(temp1,90,wndend2,3);
% %     temp2=sineb3d(temp2,90,wndend2,3);
% %     temp3=sineb3d(temp3,90,wndend2,3);
% %     temp4=sineb3d(temp4,90,wndend2,3);
%     disp('wind2 done')
%     end
% 
%     tic
%     temp1=fft(temp1,nzf2,3);
% %     temp2=fft(temp2,nzf2,3);
% %     temp3=fft(temp3,nzf2,3);
% %     temp4=fft(temp4,nzf2,3);
%     toc
%     disp('FT2 done')
% % 70sec, 36sec
%     
% %     AA=mphase3dv2(temp1,sw2,ph2,3);
% %     DA=mphase3d(temp2,sw2,ph2,3);
% %     AD=mphase3d(temp3,sw2,ph2,3);
% %     DD=mphase3d(temp4,sw2,ph2,3);
% 
% % compatible with nmrpipe, see jan1209.m.
%     AA=mphase3dv3(temp1,sw2,ph2,3);
%     disp('phase2 done')

AA=squeeze(temp1(:,:,1));
toc
disp('All done')

