clear
clc
close all 
subject_options;

%%  plot mean and SEM gmf

for sb=[1:26]
    load([matpath,'gmf_',subjname{sb},'_ICA_lp30.mat']);
    if strcmp(subjname{sb},'sub14')||strcmp(subjname{sb},'sub24')
        id(sb)=0;
    else
        id(sb)=1;
    end
    exp(sb,:)=gmf_exp.avg;
    unexp(sb,:)=gmf_unexp.avg;
end

id=logical(id);
exp = exp(id,:);
unexp = unexp(id,:);


avg_gmf1=exp;
avg_gmf2=unexp;

mean_avg_gmf1=mean(avg_gmf1,1);
sem_avg_gmf1=std(avg_gmf1,0,1)./sqrt(size(avg_gmf1,1));
mean_avg_gmf2=mean(avg_gmf2,1);
sem_avg_gmf2=std(avg_gmf2,0,1)./sqrt(size(avg_gmf2,1));


figure;
shadedErrorBar(gmf_exp.time-0.4, mean_avg_gmf1, sem_avg_gmf1,'-b',0.5);

hold on;
shadedErrorBar(gmf_exp.time-0.4, mean_avg_gmf2, sem_avg_gmf2,'-r',0.5);

xlim([-0.5 0.6])
xlabel('Time (s)');
ylabel('Global Mean Field (T)')

