[r,sd,all]=ft_bsrmsmean(x,N) - rms over channels of mean over trials, estimate sd using bootstrap r: rms of means over trials sd: standard deviation of r calculated by bootstrap all: matrix of all trials x: matrix of observations (time X repetitions or time X 1 X repetitions) N: number of bootstrap trials [default: 100]
0001 function [r,sd,all]=ft_bsrmsmean(x,N) 0002 %[r,sd,all]=ft_bsrmsmean(x,N) - rms over channels of mean over trials, estimate sd using bootstrap 0003 % 0004 % r: rms of means over trials 0005 % sd: standard deviation of r calculated by bootstrap 0006 % all: matrix of all trials 0007 % 0008 % x: matrix of observations (time X repetitions or time X 1 X repetitions) 0009 % N: number of bootstrap trials [default: 100] 0010 0011 if nargin <2; N=100; end 0012 if ndims(x) ~= 3; error('expected data to be 3D'); end 0013 0014 [m,n,o]=size(x); 0015 all=zeros(m,N); 0016 for k=1:N 0017 idx=ceil(o*rand(1,o)); 0018 all(:,k)=rms(mean(x(:,:,idx),3),2); 0019 end 0020 0021 r=rms(all,2); 0022 sd=sqrt(mean((all-repmat(r,1,N)).^2,2)); 0023 0024