function [labels_out, Minorclass, Majorclass, Seventhclass] = discard_chord_annotations(labels,parameter)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Divides chord labels into different chord classes
%
% Verena Konz 24.09.2009
%
%
%
%  parameter.chordClass
%  Redefining labels
%  0 Total
%  1 MajorMinor
%  2 Seventh
%  3 Others = Total - (MajorMinor + Seventh)
%  4 MajorMinor + Seventh
%  5 Seventh + Others
%  6 MajorMinor+ Others
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if nargin<2
   parameter=[]; 
end

if isfield(parameter,'chordClass')==0
   parameter.chordClass = 0;
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Majorclass = zeros( size(labels,1),1);
Minorclass = zeros( size(labels,1),1);
Seventhclass = zeros( size(labels,1),1);
%Test for Minorclass
for labelindex = 1: size(labels,1)
    if length(labels{labelindex})>=5
        if length(labels{labelindex}) == 5
            if findstr(labels{labelindex}, 'min')
                Minorclass(labelindex)=1;
            end
        end
        continue;
    end
    if length(labels{labelindex})>=6
        if length(labels{labelindex}) == 6
            if findstr(labels{labelindex}, 'min')
                if strcmp(labels{labelindex}(2), 'b')== 1;
                    Minorclass(labelindex)=1;
                elseif  strcmp(labels{labelindex}(2), '#')== 1
                    Minorclass(labelindex)=1;
                end
            end
        end
        continue;
    end
end

%Test for Majorclass
for labelindex = 1: size(labels,1)
    if length(labels{labelindex})>=2
        if length(labels{labelindex}) == 1
            Majorclass(labelindex)=1;
        end
        if length(labels{labelindex}) == 2
            if strcmp(labels{labelindex}(2), 'b')== 1;
                Majorclass(labelindex)=1;
            elseif  strcmp(labels{labelindex}(2), '#')== 1;
                Majorclass(labelindex)=1;
            end
        end
    elseif length(labels{labelindex})==1
        Majorclass(labelindex)=1;
        continue;
    end
end
%Test for Seventh chord
for labelindex = 1: size(labels,1)
    if findstr(labels{labelindex}, '7')
        Seventhclass(labelindex)=1;
    end
end


Majorminorclass = Majorclass+Minorclass;
Majorminorseventhclass = Majorclass+Minorclass+Seventhclass;
Remain = not(Majorminorseventhclass);
Seventhremainclass = Remain + Seventhclass;
Majorminorremainclass = Majorminorclass + Remain;
Total = Majorminorseventhclass + Remain;

% Redefining labels
%0 total
%1 for MajorMinor, 2 for Seventh, 3 for Remain, 4 for Majorminorseventh, 5
%for SeventhRemain, 6 MajorminorRemain 
labels_out = labels;
numLabels = size(labels_out,1);

if parameter.chordClass ==1
    for i=1: numLabels
        if Majorminorclass(i)==0
            labels_out{i} = 'N';
        end
    end
elseif parameter.chordClass ==2
    for i=1: numLabels
        if Seventhclass(i)==0
            labels_out{i} = 'N';
        end
    end
elseif parameter.chordClass ==3
    for i=1: numLabels
        if Remain(i)==0
            labels_out{i} = 'N';
        end
    end
elseif parameter.chordClass ==4
    for i=1: numLabels
        if Majorminorseventhclass(i)==0
            labels_out{i} = 'N';
        end
    end
elseif parameter.chordClass ==5
    for i=1: numLabels
        if Seventhremainclass(i)==0
            labels_out{i} = 'N';
        end
    end
elseif parameter.chordClass ==6
    for i=1: numLabels
        if Majorminorremainclass(i)==0
            labels_out{i} = 'N';
        end
    end
elseif parameter.chordClass ==0
    for i=1: numLabels
        if Total(i)==0
            labels_out{i} = 'N';
        end
    end
end




