function [whitesig, dewhiteM, Lambda, V, whiteM] = icatb_calculate_pca(data2, numpc)
%% Calculates principal components
%
% Inputs:
% 1. data2 - 2D array
% 2. numpc - number of principal components
%
% Outputs:
% 1. whitesig - Whitened signal
% 2. numpc - Number of principal components
%

% remove mean only for the real images for now
if isreal(data2)
    data2 = icatb_remove_mean(data2, 1);
end
% end for removing mean

saveEig = 0;

% compute covariance matrix and the eigen values
[V, Lambda] = icatb_v_pca(data2, 1, numpc, saveEig, 'untranspose', 'no');

% whiten matrix
[whitesig, whiteM, dewhiteM] = icatb_v_whiten(data2, V, Lambda, 'untranspose');

clear data2;

whitesig = whitesig';

