function out=vofvTenATimecourseBS(data)

allData=[];
numGroups=size(data,1);

for i=1:numGroups
    allData=[allData;data{i,13}];
end

reps=10000;

out=zeros(reps,1);

totalFlies=length(allData);
globalMad=mad(allData,1);

metricTemp=0;

for i=1:numGroups
    metricTemp=metricTemp+abs(globalMad-mad(data{i,13},1));
end

disp(['observed test statistic= ' num2str(metricTemp)]);

for i=1:reps
    
    
    metricTemp=0;
    
    for j=1:numGroups
        numFliesInGroup=data{j,2};
        which=rand(numFliesInGroup,1);
        which=ceil(which*totalFlies);
        
        
        metricTemp=metricTemp+abs(globalMad-mad(allData(which),1));
    end
    
    
    out(i)=metricTemp;
    h=waitbar(i/reps);
    
end

close(h);