
%A bit of MATLAB code to play with efficiency. It can be easily modified to
%estimate the efficiency of your own design. (From Russell Poldrack)

TR=2;
nruns=5000;
efficiency=zeros(1,nruns);
for x=1:nruns
   onsets=randperm(100);
   sf=zeros(1,100);
   sf(onsets(1:10))=1;
   hrf=spm_hrf(TR);
   conv_sf=conv(sf,hrf);
   conv_sf=conv_sf(1:100);
   X=[conv_sf' ones(100,1)];
   efficiency(x)=1/trace(inv(X'*X));
 end;
 hist(efficiency);

