Code covered by the BSD License  

Highlights from
TOFsPRO toolbox

from TOFsPRO toolbox by Dariya Malyarenko
Signal processing for time-of-flight mass spectra over the broad m/z range (1-200 kDa)

matchfiltAll(sigt, mfc, inhw)
function mfs = matchfiltAll(sigt, mfc, inhw)

%----------------------------------------------------
% Compute the filtered time domain signal and matched filter coefficients
%
% INPUT:
% sigt - observed sampled discrete signal with noise;
% mfc - matched filter coefficients;
% inhw - input peak HWHM in time ticks;
%
% OUTPUT:
% mfs - filtered signal
%
% USAGE:
% mfs = matchfiltAll(sigt, mfc, inhw);
% Dependency: external "xcorr" function
%

sins = size(sigt);
if sins(2) > sins(1) sigt=sigt'; end;
smfc = size(mfc);
if smfc(2) > smfc(1) mfc=mfc'; end;

Nw=length(mfc); Ns=length(sigt);
sf=xcorr(sigt, mfc);

if ((Nw/2) ~= (floor(Nw/2)))
sf=sf((Ns-floor(0.825*Nw)+1):(2*Ns-floor(0.825*Nw)));
else
sf=sf((Ns-floor(0.825*Nw)+2):(2*Ns-floor(0.825*Nw)+1)); %% to correct phase shift
end;

outs=sf*sum(sigt)/sum(sf);

mxlag = floor(length(outs)/7);
[cf, lags]= xcorr(sigt((3*mxlag+1):(4*mxlag)),outs((3*mxlag+1):(4*mxlag)),mxlag);
%plot(cf)
[ycf, icf]=max(cf);
icf;
shift1 = icf-mxlag-1; 

%ss=xcorr(sigt, outs);
%[ymx, imx]=max(ss);
%shift1=imx-Ns-1;
outs=circshift(outs, shift1+fix(inhw/2)); % correct shift
l1 = length(outs);

%% correct for filter shift into early points 11/14/07
outs((end-floor(Nw/3)):end) = sigt((end-floor(Nw/3)):end); 
mfs = outs(1:l1); 


return;

Contact us at files@mathworks.com