%%%%%%%%%%%%%%%%%%%%%%%
% %
% STS_scale %
% %
%%%%%%%%%%%%%%%%%%%%%%%
% To be called by sts_algorithm
%STS scale.
%
% function [X, t, X_original, t_original] = fsts_scaling(X, t)
% The data set X is z-score standardise (transformed to have zero mean and standard deviation of one) and two fixed time points
% are added at the begining of the series with a value of zero. The original time points are scaled down by substraction to start as t3=1.
function [X, t, X_original, t_original] = sts_scale(X, t)
X_original=X;
t_original=t;
[n_g,n_t]=size(X);
%subtract the mean
mean_values=mean(X')';
mean_matrix=mean_values*ones(1,n_t);
X=X-mean_matrix;
%divide by the standard diviation
standard_dev=std(X')';
std_matrix=standard_dev*ones(1,n_t);
X=X./std_matrix;
% Add two time points with zero and sacle down the original time points
X=[zeros(n_g,2) X];
t=t-t(1)+1;
t=[-1 0 t];