function []=nic_get_average_brain()
s=dir();
olddir=pwd;
outputdir='D:\test\';
for i=3:size(s),
    cd(olddir);
    Name=s(i).name;
    cd(Name);
    a=ls('*.img');
    avg=[];
    for j=1:size(a,2)
        fileimg=[olddir,'\',Name,'\',a(j,:)];
        [data,head]=nic_ReadNiftiImage(fileimg);
        if(size(avg,1)==0)
            avg=zeros(size(data));
        end
        avg=avg+data;
    end
    avg=avg/size(a,2);
    nic_WriteNiftiImage(avg,head,[outputdir,Name,'.img']);
end