load('428_PA.mat')
ISOZ = {};
ESOZ = {};
INOZ = {};
ENOZ = {};
for ss = 1:length(spikephase)
    if length(spikephase{1,ss}) > 1
        if (spikephase{2,ss} == 'ISOZ')
            disp(1)
            ISOZ{1,end+1} = cell2mat(spikephase(1,ss));
        elseif  spikephase{2,ss} ==  'ESOZ'
            disp(2)
            ESOZ{1,end+1} = cell2mat(spikephase(1,ss));
        elseif spikephase{2,ss} == 'INOZ'
            disp(3)
            INOZ{1,end+1} = cell2mat(spikephase(1,ss));
        else
            disp(4)
            ENOZ{1,end+1} = cell2mat(spikephase(1,ss));
        end
    end
end

for cc =  1:length(spikephase)
    angles = cell2mat(spikephase(1,cc));
    if length(angles)>1
        [MA] = circ_mean(angles');
        STD = circ_std(angles'); 
        [p,z] = circ_rtest(angles');
        disp('-----------')
        disp(cc)
        disp(spikephase(2,cc))
        disp(strcat('Z-score:  ', num2str(z)))
        disp(strcat('Mean:  ', num2str(360/(2*3.141592654)*MA), '+-', num2str(360/(2*3.141592654)*STD/(length(angles))^(1/2))))
        %disp(strcat('Standard Error:  ', num2str(3.141592654*STD/length(spikephase))))
        disp(strcat('p-value:  ', num2str(p)))
        %disp(STD)
        
    else
        disp('-------------')
        disp(cc)
    end
    
end
disp('-------------')
disp('-------------')
disp(length(ESOZ))
disp(length(ISOZ))
disp(length(ENOZ))
disp(length(INOZ))

