function [out, v, m] = prewhite( in) % save as prewhite.m
echo off
% De-bias
m = mean( in');
'entering whitening loop'
for i = 1:rows(in)
	if(mod(i,250) == 0)
		i
	end
        out(i,:) = (in(i,:) - m(i));
end
'Decorrelating'
size(out)
gout = out;
% Decorrelate
v = 2 * sqrtm( inv( out * out'));
out = v * out;
