%% scale the SAP by std
function [ output_args ] = plot_SAP_STD(ddd,ddd2,myTitle,computeMethod,pValue)
figure;
if(strcmp(computeMethod,'std'))
    temp = (std(ddd,[],3));
    temp2 = (std(ddd2,[],3));
elseif(strcmp(computeMethod , 'mean'))
    temp = squeeze(mean(ddd,3));
    temp2 = squeeze(mean(ddd2,3));
end
temp = temp(:,any(temp));
temp2 = temp2(:,any(temp2));
rscale = [ 4.2 10.5 17.5];
%     session_A_s_index = [1 3 5 7 9 11 14 16 18 20];
%     session_B_s_index = [2 4 6 8 10 12 13 15 17 19];
%     selectedSector = zeros(size(ddd,1),1);
%     selectedSector(session_A_s_index,1) = data(session_A_s_index,1);
%     selectedSector(session_B_s_index,1) = data(session_B_s_index,2);

%% check STD of two datasets for each frequence
for i=1:size(temp,1)
    [h,p,ci] = ttest2(temp(i,:),temp2(i,:),pValue);
    if(h ==1)
        colorScaled(i) = 1;%white
    else
        [h,p,ci] = ttest2(temp(i,:),temp2(i,:),pValue*10);
        if(h ==1)
            colorScaled(i) = 0.7;%gray
        else
            [h,p,ci] = ttest2(temp(i,:),temp2(i,:),pValue*100);
            if(h ==1)
                colorScaled(i) = 0.4;%gray
            else
                colorScaled(i) = 0;%black
            end
        end
    end
end
    if(size(ddd,1)==39)
        colorIndex = [1:2:39];
        %     colorIndex = [2:2:38 39];
    else
        colorIndex = [1:20];
    end
    t=0:0.001:1;
    %inner ring
    s1=rscale(1)*sin(2*pi/4*t);
    c1=rscale(1)*cos(2*pi/4*t);
    s2=rscale(1)*sin(2*pi/4*(t+1));
    c2=rscale(1)*cos(2*pi/4*(t+1));
    s3=rscale(1)*sin(2*pi/4*(t+2));
    c3=rscale(1)*cos(2*pi/4*(t+2));
    s4=rscale(1)*sin(2*pi/4*(t+3));
    c4=rscale(1)*cos(2*pi/4*(t+3));
    %middle ring
    s5=rscale(2)*sin(2*pi/8*t);
    c5=rscale(2)*cos(2*pi/8*t);
    s6=rscale(2)*sin(2*pi/8*(t+1));
    c6=rscale(2)*cos(2*pi/8*(t+1));
    s7=rscale(2)*sin(2*pi/8*(t+2));
    c7=rscale(2)*cos(2*pi/8*(t+2));
    s8=rscale(2)*sin(2*pi/8*(t+3));
    c8=rscale(2)*cos(2*pi/8*(t+3));
    s9=rscale(2)*sin(2*pi/8*(t+4));
    c9=rscale(2)*cos(2*pi/8*(t+4));
    s10=rscale(2)*sin(2*pi/8*(t+5));
    c10=rscale(2)*cos(2*pi/8*(t+5));
    s11=rscale(2)*sin(2*pi/8*(t+6));
    c11=rscale(2)*cos(2*pi/8*(t+6));
    s12=rscale(2)*sin(2*pi/8*(t+7));
    c12=rscale(2)*cos(2*pi/8*(t+7));
    %outter ring
    s13=rscale(3)*sin(2*pi/8*t);
    c13=rscale(3)*cos(2*pi/8*t);
    s14=rscale(3)*sin(2*pi/8*(t+1));
    c14=rscale(3)*cos(2*pi/8*(t+1));
    s15=rscale(3)*sin(2*pi/8*(t+2));
    c15=rscale(3)*cos(2*pi/8*(t+2));
    s16=rscale(3)*sin(2*pi/8*(t+3));
    c16=rscale(3)*cos(2*pi/8*(t+3));
    s17=rscale(3)*sin(2*pi/8*(t+4));
    c17=rscale(3)*cos(2*pi/8*(t+4));
    s18=rscale(3)*sin(2*pi/8*(t+5));
    c18=rscale(3)*cos(2*pi/8*(t+5));
    s19=rscale(3)*sin(2*pi/8*(t+6));
    c19=rscale(3)*cos(2*pi/8*(t+6));
    s20=rscale(3)*sin(2*pi/8*(t+7));
    c20=rscale(3)*cos(2*pi/8*(t+7));
    %outter ring
    patch([0,s13],[0,c13],[1 1 1]*colorScaled(colorIndex(13)),'linewidth',2);
    patch([0,s14],[0,c14],[1 1 1]*colorScaled(colorIndex(14)),'linewidth',2);
    patch([0,s15],[0,c15],[1 1 1]*colorScaled(colorIndex(15)),'linewidth',2);
    patch([0,s16],[0,c16],[1 1 1]*colorScaled(colorIndex(16)),'linewidth',2);
    patch([0,s17],[0,c17],[1 1 1]*colorScaled(colorIndex(17)),'linewidth',2);
    patch([0,s18],[0,c18],[1 1 1]*colorScaled(colorIndex(18)),'linewidth',2);
    patch([0,s19],[0,c19],[1 1 1]*colorScaled(colorIndex(19)),'linewidth',2);
    patch([0,s20],[0,c20],[1 1 1]*colorScaled(colorIndex(20)),'linewidth',2);
    %middle ring
    patch([0,s5],[0,c5],[1 1 1]*colorScaled(colorIndex(5)),'linewidth',2);
    patch([0,s6],[0,c6],[1 1 1]*colorScaled(colorIndex(6)),'linewidth',2);
    patch([0,s7],[0,c7],[1 1 1]*colorScaled(colorIndex(7)),'linewidth',2);
    patch([0,s8],[0,c8],[1 1 1]*colorScaled(colorIndex(8)),'linewidth',2);
    patch([0,s9],[0,c9],[1 1 1]*colorScaled(colorIndex(9)),'linewidth',2);
    patch([0,s10],[0,c10],[1 1 1]*colorScaled(colorIndex(10)),'linewidth',2);
    patch([0,s11],[0,c11],[1 1 1]*colorScaled(colorIndex(11)),'linewidth',2);
    patch([0,s12],[0,c12],[1 1 1]*colorScaled(colorIndex(12)),'linewidth',2);
    %inner ring
    patch([0,s1],[0,c1],[1 1 1]*colorScaled(colorIndex(1)),'linewidth',2);
    patch([0,s2],[0,c2],[1 1 1]*colorScaled(colorIndex(2)),'linewidth',2);
    patch([0,s3],[0,c3],[1 1 1]*colorScaled(colorIndex(3)),'linewidth',2);
    patch([0,s4],[0,c4],[1 1 1]*colorScaled(colorIndex(4)),'linewidth',2);
    hold on;
    %lines
    rs1=rscale(1)*sin(2*pi*t);
    rc1=rscale(1)*cos(2*pi*t);
    rs2=rscale(2)*sin(2*pi*t);
    rc2=rscale(2)*cos(2*pi*t);
    rs3=rscale(3)*sin(2*pi*t);
    rc3=rscale(3)*cos(2*pi*t);
    plot(rs1,rc1,'k',rs2,rc2,'k',rs3,rc3,'k','linewidth',2);
    gca;
    
    % set(gca,'linewidth',4)
    plot([-rscale(3) rscale(3)],[0 0],'k','linewidth',2);
    plot([0 0],[-rscale(3) rscale(3)],'k','linewidth',2);
    xlim([-18 18]);
    ylim([-18 18]);
    set(gca,'XTick',[-20:5:20]);
    % set(gca,'XTickLabelRotation',45);
    box off;
    ylabel('degree');
    xlabel('degree');
    set(gca,'fontsize',20)
    axis equal;
    title(myTitle);
    % h = colorbar;
    % h.Limits = [0.005 0.5]
    % colormap('gray');
    % caxis([0.05 0.5]);
end

