%% correctratio function plots the recognition ratio of correct realiyation of the emotion of the experiment
%% Input
% path: path to data
% efed: experiment (EFE1/EFE2; EFED1/EFED2)
%% Output
% graph showing recognition ratio for each emotion
function correctratio(path, efed)
load(path)
emotion={'N','F','D','S','G'};
final=[];
for a=1:5
    correct=0;
    k=0;
    emo=emotion(a);
    for i=1:length(fieldnames(EventFix.(efed)))
        subj=fieldnames(EventFix.(efed));
        subj=subj(i,1);
        subj=subj{1,1};
         for j=1:length(EventFix.(efed).(subj))
                nature=EventFix.(efed).(subj)(1,j).Nature; 
                if strcmp (nature, emo) % to check for the right video
                    k=k+1;
                    if EventFix.(efed).(subj)(1,j).AnswerStatus==1
                        correct=correct+1;
                    else 
                        correct=correct;
                    end
                else
                    k=k;
                    correct=correct;
                end
         end
    end
    total(a,1)=k;
    final(a,1)=correct;
end
CAratio=(final./total);
bar(CAratio, 0.4,'red')
ylim([0 1])
title(sprintf('Correct recognition of stimuli emotion, %s', efed), 'fontsize', 16)
Labels={'Neutral','Fear', 'Disgust', 'Surprise', 'Happiness'};
xlabel('Emotions', 'fontsize', 16)
ylabel('Correct answer ratio','fontsize',16)
set(gca,'XTick', 1:5, 'XTickLabel', Labels);

