function [Amp, Latency] = ave_peak(Datastack,sign,t1,t2,pre); % averages over all locations. finds positive or negative peak of this % average timecourse for each epoch. % if sign is 1, find the positive peak. if sign is -1, finds negative peak. MeanData = mean(Datastack); MeanData = permute(MeanData,[2,3,1]); MeanData = sign*MeanData; [Amp, Latency] = peak(MeanData,t1,t2,pre); end