function  [A,B] = pkg(clpname)
global A
global B


precalc = 1;
addpath('c:\');
addpath('c:\');


fid=openclp(clpname);
Info=readinfo(fid,0);
frames =getparam('framesiq',Info,0);
fd =getparam('fdemodiq',Info,0) / 1e6;
fs =getparam('frsiq',Info,0) / 1e6;

A = cell(1,frames); % first harm.
B = cell(1,frames); % second harm.

iq = readiq(fid,Info,10);
N = size(iq,1);
NN = 2048;  % zeropadding extent to avoid ringing artifacts
beams = size(iq,2);

%% show spectrum and test filtering

freq = double(-floor(NN/2):ceil(NN/2)-1)/NN*fs + fd;
SP = mean(abs(fft(iq,NN))');
%figure(5);subplot(3,1,1);plot(freq,fftshift(SP));

IQ=fftshift(fft(iq,NN));

order = 25;
locus = 3;
d = freq / locus;
Butt1 = 1./(1+d.^(2*order));
Butt11 = repmat(Butt1', 1, beams);
%
locus = 4;
d = freq / locus;
Butt2 = 1./(1+d.^(2*order));
Butt2 = max(Butt2)-Butt2;
Butt22 = repmat(Butt2', 1, beams);
%
%figure(6);
%subplot(2,1,1);plot(freq,Butt1);
%subplot(2,1,2);plot(freq,Butt2);

IQ1 = IQ .* Butt11;
IQ2 = IQ .* Butt22;
iq1=ifft(fftshift(IQ1));
iq2=ifft(fftshift(IQ2));
%
SP = mean(abs(fft(iq1))');
%figure(5);subplot(3,1,2);plot(freq,fftshift(SP));
SP = mean(abs(fft(iq2))');
%figure(5);subplot(3,1,3);plot(freq,fftshift(SP));

% pause

% figure(6);
% subplot(2,1,1);imagesc(log(0.0001 + abs(iq1) ));
% subplot(2,1,2);imagesc(log(0.0001 + abs(iq2) ));


%%

h = waitbar(0,'Please wait...');
tic

if precalc

    frame = 1;
    for f=1:1:frames  %for each frame
%         disp( 100*f/frames )
        iq = readiq(fid,Info,f);
        IQ = fftshift(fft(iq,NN));
        IQ1 = IQ .* Butt11;
        IQ2 = IQ .* Butt22;
        iq1=ifft(fftshift(IQ1));
        iq2=ifft(fftshift(IQ2));
        iq1=iq1(1:N,:);
        iq2=iq2(1:N,:);
        env1st = abs(iq1);
        env2nd = abs(iq2);

        %     A{frame}=env2nd;

        [OutIm1,HCm,WCm,SCmap] = scanconv( env1st, Info, 246*2, 265*2  );% Height,Width,RadI,LatI,Background)
        [OutIm2,HCm,WCm,SCmap] = scanconv( env2nd, Info, 246*2, 265*2  );% Height,Width,RadI,LatI,Background)
        size(OutIm1);
        %     figure(21); imagesc(log(0.0001+OutIm1));
        %     figure(22); imagesc(log(0.0001+OutIm2));
        OutIm1=mat2gray(OutIm1);
        OutIm1=OutIm1*5;
        OutIm2=(mat2gray(OutIm2))*5;
        A{frame}=OutIm1;
        B{frame}=OutIm2;

        %     pause;
        % waitbar update
        timestr = ['Converting from "clp" to "cell"  ...   Time remaining:' remain_time(frame,frames)];
        waitbar(frame/frames,h,timestr);

        frame = frame + 1;
    end
    close(h);
    
else
    
end