function [datastack] = normalize2(datastack) %this function normalizes the data for each sensor for each time over all the epochs into z scores. %NormalizedData = zeros(length(datastack(:,1,1)),length(datastack(1,:,1)),length(datastack(1,1,:))); Mean = mean(datastack,3); Std = std(datastack,0,3); for h = 1:length(datastack(1,:,1)) for j = 1:length(datastack(1,1,:)) for k = 1:length(datastack(:,1,1)) datastack(k,h,j) = ((datastack(k,h,j) - Mean(k,h)) / (Std(k,h))); end end end;