
function barscatter_dnnlayers(data,cmap,layerNum,layerNames)

    figure('Renderer','painters','Position',[600 750 350 200]);
    gcf();
    
    n_subs = size(data,1);
    disp(['post-hoc t-test over ERS cluster time average'])
    for layer = 1:size(data,2)
        h = bar(layer,nanmean(data(:,layer),1),'FaceColor',cmap(layer,:)); hold on;
        h = scatter(repmat(layer,n_subs,1),squeeze(data(:,layer)),15,'filled'); h.MarkerEdgeColor = 'black';  h.MarkerFaceColor = cmap(layer,:);
        
        [h,p,ci,stat] = ttest(squeeze(data(:,layer)));
        disp(['layer' num2str(layer) ' t = ' num2str(stat.tstat) ' , p = ' num2str(p) ' , df = ' num2str(stat.df)])
    end
    
    set(gcf,'color','white');
    set(gca,'XTick',1:layerNum,'XTickLabel',layerNames)
    set(gca,'FontSize',15)
    xtickangle(90)
    ylabel('t-value')
    ylim([-3 3])
    
    %plot bar with sem no scatter
    figure('Renderer','painters','Position',[600 750 350 200]);
    gcf();
    
    n_subs = size(data,1);
    disp(['post-hoc t-test over ERS cluster time average'])
    for layer = 1:size(data,2)
        vals = squeeze(data(:,layer));
        sem = std(vals) ./ sqrt(length(vals));
        h = bar(layer,nanmean(vals,1),'FaceColor',cmap(layer,:)); hold on;
        e = errorbar(layer,nanmean(vals,1),sem,'Color','black'); hold on;
    end
    set(gcf,'color','white');
    set(gca,'XTick',1:layerNum,'XTickLabel',layerNames)
    set(gca,'FontSize',15)
    xtickangle(90)
    ylabel('t-value')
    %ylim([-2 3])
end
    
   