%
%   NMR experiment: Bumps + Peak + Noise -> Bumps
%   remove an undesired peak from a signal
%   by manipulating the wavelet coefficients
%
%           Peak = Crease = exp(-4*abs(t - .37));
%
	n = 4096;
	t  = (1:n) ./n;
	randn('seed',931316785);
	witruis = randn(1,n);
	Crease = exp(-20*abs(t - .70));
	Bumps = MakeSignal('Bumps',n);
	BCrease = Bumps + 20* Crease + 0.5* witruis;

% now we got the signal
%
	figure(1); plot(t,BCrease); title('Bumps+Peak+Noise')
	%%print -deps /home/ade/SIGNALS/BumpsPeakNoise.eps

% compute the wavelet transform (Coiflet)
% of all the signals involved: Crease, Bumps, Bumps+Crease

    wavelet = 'Coiflet';
	qmf = MakeONFilter(wavelet,3);
	wcCrease = FWT_PO(Crease,0,qmf);            
	wcBumps = FWT_PO(Bumps,0,qmf);
	wcBCrease = FWT_PO(BCrease,0,qmf);

	figure(2); PlotWaveCoeff(wcBCrease,0,.01); title('WT Bumps+Peak+Noise');
	figure(3); PlotWaveCoeff(20*wcCrease,0,0.01); title('WT Peak');
	%%print -deps /home/ade/SIGNALS/WTPeak.eps
	figure(5); PlotMultiRes(wcCrease,1,1,qmf); title('MRA Peak');
	%%print -deps /home/ade/SIGNALS/MRAPeak.eps
%
% remove unwanted wavelet coefs for the peak

	 wcBCrease(1:9) = 0; wcBCrease(12:13) = 0; wcBCrease(14:17) = 0;
         wcBCrease(25:28) = 0; wcBCrease(30:33) = 0; wcBCrease(53:55) = 0;
         wcBCrease(62:65) = 0; wcBCrease(108:113) = 0;

% inverse transform

	out = IWT_PO(wcBCrease,0,qmf);

	figure(4); plot(wcCrease(1:256)); title('WT Peak');
	%%print -deps /home/ade/SIGNALS/WCPeak.eps

% do the SURE thresholding to remove noise

	[xh,xwh] = WaveShrink(out,'SURE',4,qmf);

	figure(6); plot(t,xh,t,20+Bumps,t,10+out);
        title('Bumps / Bumps-Peak / Bumps-Peak-Noise');
	%%print -deps /home/ade/SIGNALS/CleanBumpsPeak.eps
