function [Y, orig_mean] = GIG_RemoveMean(X)
%% Remove mean of each column and return original mean values in a vector.
%% 每列减去列均值
%
% Inputs:
% X - X is 2D double array. 这里应为像素数*时间点数

%
% Outputs:
% 1. Y - Data with zero mean
% 2. orig_mean - Original mean values

% written by duyuhui, CAS,China,2011
Y=zeros(size(X));
orig_mean = mean(X);
%% Remove mean of sample one at a time  速度慢但所用memory少（相对于 repmat）
    for nM = 1:size(X, 2)
        Y(:, nM) = X(:, nM) - orig_mean(nM);
    end
end

