function y = cbsi(oxy, deoxy)
% function y = cbsi(oxy, deoxy)
% assume the original signal is oxy and deoxy, and the corrected signal is
% oxy0.
%
% Xu Cui
% Stanford University
% 2009/09/28

% offline version (post-experiment data analysis)
alpha = std(oxy)./std(deoxy);
oxy0 = oxy - repmat(alpha, size(oxy,1),1) .* deoxy;
y = oxy0/2;
% % online version (real time)
% windowSize = 100;
% for kk=2:N % as time goes, more and more data is coming
%     alpha = std(oxy(max(1,kk-windowSize*10):kk,:)) ./ std(deoxy(max(1,kk-windowSize*10):kk,:));
%     oxy0(kk) = oxy(kk) - alpha .* deoxy(kk);
% end