Dawn@4: function [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames,... Dawn@4: masterFileOutputID, distanceMeasure ) Dawn@4: Dawn@4: groupNames = char(groupNames); Dawn@4: Dawn@4: % for emotion detection give the confusion matrix as Dawn@4: % ----------------------------------------------------------------- Dawn@4: % positive correctly identified | positive incorrectly identified (1,2) Dawn@4: % negative incorrectly identified (2,1) | negative correctly identified Dawn@4: % ------------------------------------------------------------------ Dawn@4: % which group has the most samples? Dawn@4: [maxValue, maxIndex] = max( groupStats ); Dawn@4: maxGroup = groupNames( maxIndex,: ); Dawn@4: Dawn@4: % if we are performing emotion detection Dawn@4: if( ~isempty(strfind( groupNames(1,:), 'N' )) ... Dawn@4: || ~isempty(strfind( groupNames(1,:), 'P' ))) Dawn@4: confusionMatrix = zeros(2,2); Dawn@4: Dawn@4: % check groups for any missing Dawn@4: if( length(groupStats) < 4 ) Dawn@4: % find the missing group Dawn@4: if( groupFind( groupNames, 'N1' ) == 0 ) Dawn@4: % missing N1 Dawn@4: groupNames = [groupNames; 'N1']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'N2' ) == 0 ) Dawn@4: % missing N2 Dawn@4: groupNames = [groupNames; 'N2']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'P1' ) == 0 ) Dawn@4: % missing P1 Dawn@4: groupNames = [groupNames; 'P1']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'P2' ) == 0 ) Dawn@4: %missing P2 Dawn@4: groupNames = [groupNames; 'P2']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: end Dawn@4: % let the group with the maximum success (either 1 or 2) be the Dawn@4: % cluster for that emotion Dawn@4: if( strfind( maxGroup, 'N' )) Dawn@4: % negative samples were detected most reliably Dawn@4: confusionMatrix(2,2) = maxValue; Dawn@4: if( strfind( maxGroup, '1' )) Dawn@4: % group 1 is the negative group Dawn@4: % find the number of positive samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'P1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % group 2 is the positive group Dawn@4: % find the number of positive samples correctly identified Dawn@4: idx = groupFind( groupNames, 'P2' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: % find the number of negative samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'N2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: else Dawn@4: % group 2 is the negative group Dawn@4: % find the number of positive samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'P2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % group 1 is the positive group Dawn@4: % find the number of positive samples correctly identified Dawn@4: idx = groupFind( groupNames, 'P1' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: % find the number of negative samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'N1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: end Dawn@4: else Dawn@4: % positive samples were detected most reliably Dawn@4: confusionMatrix(1,1) = maxValue; Dawn@4: if( strfind( maxGroup, '1' )) Dawn@4: % group 1 is the positive group Dawn@4: % find the number of positive samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'P2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % group 2 is the negative group Dawn@4: % find the number of negative samples correctly identified Dawn@4: idx = groupFind( groupNames, 'N2' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % find the number of negative samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'N1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: else Dawn@4: % group 2 is the positive group Dawn@4: % find the number of positive samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'P1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % group 1 is the negative group Dawn@4: % find the number of negative samples correctly identified Dawn@4: idx = groupFind( groupNames, 'N1' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % find the number of negative samples incorrectly identified Dawn@4: idx = groupFind( groupNames, 'N2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: end Dawn@4: end Dawn@4: Dawn@4: confusionMatrix(3,3) = confusionMatrix(1,1) + confusionMatrix(2,2); Dawn@4: disp(distanceMeasure); Dawn@4: % print latex results to the screen Dawn@4: str1 = sprintf(' & %2.2f & %2.2f & \\\\', confusionMatrix(1,1), confusionMatrix(1,2) ); Dawn@4: disp(str1); Dawn@4: str1 = sprintf(' & %2.2f & %2.2f & \\\\', confusionMatrix(2,1), confusionMatrix(2,2) ); Dawn@4: disp(str1); Dawn@4: str1 = sprintf(' & & & %2.2f \\\\',confusionMatrix(3,3) ); Dawn@4: disp(str1); Dawn@4: disp(' '); Dawn@4: Dawn@4: fprintf( masterFileOutputID, '\n %f \t %f \n %f \t %f \n %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(2,1), confusionMatrix(2,2), 0, 0, confusionMatrix(3,3)); Dawn@4: end Dawn@4: Dawn@4: % for gender detection give the confusion matrix as Dawn@4: % -------------------------------------------------------------------- Dawn@4: % male correctly identified as male | male incorrectly identified as female | male incorrectly identified as trans Dawn@4: % female incorrectly identified as male | female correctly identified | female incorrectly identified as trans Dawn@4: % trans incorrectly identified as male | trans incorrectly identified as female | trans correctly identified Dawn@4: % -------------------------------------------------------------------- Dawn@4: Dawn@4: % if we are performing gender detection Dawn@4: if( ~isempty(strfind( groupNames(1,:), 'F' )) ... Dawn@4: || ~isempty(strfind( groupNames(1,:), 'M' ))... Dawn@4: || ~isempty(strfind( groupNames(1,:), 'T' ))) Dawn@4: confusionMatrix = zeros(3,3); Dawn@4: Dawn@4: % check groups for any missing Dawn@4: if( length(groupStats) < 9 ) Dawn@4: % find the missing group Dawn@4: if( groupFind( groupNames, 'M1' ) == 0 ) Dawn@4: groupNames = [groupNames; 'M1']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'M2' ) == 0 ) Dawn@4: groupNames = [groupNames; 'M2']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'M3' ) == 0 ) Dawn@4: groupNames = [groupNames; 'M3']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'F1' ) == 0 ) Dawn@4: groupNames = [groupNames; 'F1']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'F2' ) == 0 ) Dawn@4: groupNames = [groupNames; 'F2']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'F3' ) == 0 ) Dawn@4: groupNames = [groupNames; 'F3']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'T1' ) == 0 ) Dawn@4: groupNames = [groupNames; 'T1']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'T2' ) == 0 ) Dawn@4: groupNames = [groupNames; 'T2']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: if( groupFind( groupNames, 'T3' ) == 0 ) Dawn@4: groupNames = [groupNames; 'T3']; Dawn@4: groupStats = [groupStats 0]; Dawn@4: end Dawn@4: Dawn@4: end Dawn@4: Dawn@4: Dawn@4: % let the group with the maximum success (either 1, 2 or 3) be the Dawn@4: % cluster for that gender Dawn@4: if( strfind( maxGroup, 'M' )) Dawn@4: % male samples were detected most reliably Dawn@4: confusionMatrix(1,1) = maxValue; Dawn@4: if( strfind( maxGroup, '1' )) Dawn@4: % group 1 is the male group Dawn@4: % find the female group (F2 or F3, can't be F1) Dawn@4: idx1 = groupFind( groupNames, 'F2' ); Dawn@4: idx2 = groupFind( groupNames, 'F3' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % group 1 is the male group Dawn@4: % female is group 2 and trans group 3 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % female is group 3 and trans is group 2 Dawn@4: Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: Dawn@4: elseif( strfind( maxGroup, '2' )) Dawn@4: % group 2 is the male group Dawn@4: Dawn@4: % find the female group (F1 or F3, can't be F2) Dawn@4: idx1 = groupFind( groupNames, 'F1' ); Dawn@4: idx2 = groupFind( groupNames, 'F3' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % female is group 1 and trans group 3 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % female is group 3 and trans is group 1 Dawn@4: Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: else Dawn@4: % group 3 is the male group Dawn@4: Dawn@4: % find the female group (F1 or F2, can't be F3) Dawn@4: idx1 = groupFind( groupNames, 'F1' ); Dawn@4: idx2 = groupFind( groupNames, 'F2' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % female is group 1 and trans group 2 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % female is group 2 and trans is group 1 Dawn@4: Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: end Dawn@4: Dawn@4: % -------------------------------------------------------------------- Dawn@4: % male correctly identified as male (1,1) | male incorrectly identified as female (1,2) | male incorrectly identified as trans Dawn@4: % female incorrectly identified as male (2,1) | female correctly identified (2,2) | female incorrectly identified as trans Dawn@4: % trans incorrectly identified as male (3,1) | trans incorrectly identified as female (3,2) | trans correctly identified (3,3) Dawn@4: % -------------------------------------------------------------------- Dawn@4: Dawn@4: elseif( strfind( maxGroup, 'F' )) Dawn@4: % female samples were detected most reliably Dawn@4: confusionMatrix(2,2) = maxValue; Dawn@4: if( strfind( maxGroup, '1' )) Dawn@4: % group 1 is the female group Dawn@4: % find the male group (F2 or F3, can't be F1) Dawn@4: idx1 = groupFind( groupNames, 'M2' ); Dawn@4: idx2 = groupFind( groupNames, 'M3' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % male is group 2 and trans group 3 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % female is group 1 Dawn@4: % male is group 3 and trans is group 2 Dawn@4: Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: Dawn@4: elseif( strfind( maxGroup, '2' )) Dawn@4: % group 2 is the female group Dawn@4: % find the male group (M1 or M3, can't be M2) Dawn@4: idx1 = groupFind( groupNames, 'M1' ); Dawn@4: idx2 = groupFind( groupNames, 'M3' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % male is group 1 and trans group 3 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % group 2 is the female group Dawn@4: % male is group 3 and trans is group 1 Dawn@4: Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: else Dawn@4: % group 3 is the female group Dawn@4: % find the male group (M1 or M2, can't be M3) Dawn@4: idx1 = groupFind( groupNames, 'M1' ); Dawn@4: idx2 = groupFind( groupNames, 'M2' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % male is group 1 and trans group 2 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % female is group 3 Dawn@4: % male is group 2 and trans is group 1 Dawn@4: Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans correctly identified as trans Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,3) = groupStats( idx ); Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: end Dawn@4: % -------------------------------------------------------------------- Dawn@4: % male correctly identified as male (1,1) | male incorrectly identified as female (1,2) | male incorrectly identified as trans Dawn@4: % female incorrectly identified as male (2,1) | female correctly identified (2,2) | female incorrectly identified as trans Dawn@4: % trans incorrectly identified as male (3,1) | trans incorrectly identified as female (3,2) | trans correctly identified (3,3) Dawn@4: % -------------------------------------------------------------------- Dawn@4: Dawn@4: elseif( strfind( maxGroup, 'T' )) Dawn@4: % trans samples were detected most reliably Dawn@4: confusionMatrix(3,3) = maxValue; Dawn@4: if( strfind( maxGroup, '1' )) Dawn@4: % group 1 is the trans group Dawn@4: % find the female group (F2 or F3, can't be F1) Dawn@4: idx1 = groupFind( groupNames, 'F2' ); Dawn@4: idx2 = groupFind( groupNames, 'F3' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % female is group 2 and male group 3 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % female is group 3 and male is group 2 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: end Dawn@4: Dawn@4: elseif( strfind( maxGroup, '2' )) Dawn@4: % group 2 is the trans group Dawn@4: % find the female group (F1 or F3, can't be F2) Dawn@4: idx1 = groupFind( groupNames, 'F1' ); Dawn@4: idx2 = groupFind( groupNames, 'F3' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % female is group 1 and male group 3 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % group 2 is the trans group Dawn@4: % female is group 3 and male is group 1 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T3' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: else Dawn@4: % group 3 is the trans group Dawn@4: % find the female group (F1 or F2, can't be F3) Dawn@4: idx1 = groupFind( groupNames, 'F1' ); Dawn@4: idx2 = groupFind( groupNames, 'F2' ); Dawn@4: if( groupStats( idx1 ) > groupStats( idx2 ) ) Dawn@4: % female is group 1 and male group 2 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: Dawn@4: else Dawn@4: % group 3 is the trans group Dawn@4: % female is group 2 and male is group 1 Dawn@4: % find the number of male samples incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'M2' ); Dawn@4: confusionMatrix(1,2) = groupStats( idx ); Dawn@4: % find the number of male samples incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'M3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: % male correctly identified as male Dawn@4: idx = groupFind( groupNames, 'M1' ); Dawn@4: confusionMatrix(1,1) = groupStats( idx ); Dawn@4: Dawn@4: % female correctly identified as female Dawn@4: idx = groupFind( groupNames, 'F2' ); Dawn@4: confusionMatrix(2,2) = groupStats( idx ); Dawn@4: % female incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'F1' ); Dawn@4: confusionMatrix(2,1) = groupStats( idx ); Dawn@4: % female incorrectly identified as trans Dawn@4: idx = groupFind( groupNames, 'F3' ); Dawn@4: confusionMatrix(1,3) = groupStats( idx ); Dawn@4: Dawn@4: % trans incorrectly identified as male Dawn@4: idx = groupFind( groupNames, 'T1' ); Dawn@4: confusionMatrix(3,1) = groupStats( idx ); Dawn@4: % trans incorrectly identified as female Dawn@4: idx = groupFind( groupNames, 'T2' ); Dawn@4: confusionMatrix(3,2) = groupStats( idx ); Dawn@4: end Dawn@4: Dawn@4: end Dawn@4: end Dawn@4: Dawn@4: confusionMatrix(4,4) = confusionMatrix(1,1) + confusionMatrix(2,2) + confusionMatrix(3,3); Dawn@4: disp(distanceMeasure); Dawn@4: % print latex results to the screen Dawn@4: str1 = sprintf(' & %2.2f & %2.2f & %2.2f & \\\\', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(1,3) ); Dawn@4: disp(str1); Dawn@4: str1 = sprintf(' & %2.2f & %2.2f & %2.2f & \\\\', confusionMatrix(2,1), confusionMatrix(2,2), confusionMatrix(2,3) ); Dawn@4: disp(str1); Dawn@4: str1 = sprintf(' & & & & %2.2f \\\\',confusionMatrix(4,4) ); Dawn@4: disp(str1); Dawn@4: disp(' '); Dawn@4: Dawn@4: fprintf( masterFileOutputID, '\n %f \t %f \t %f \n %f \t %f \t %f \n %f \t %f \t %f \n %f \t %f \t %f \t %f \n', confusionMatrix(1,1), confusionMatrix(1,2), confusionMatrix(1,3), confusionMatrix(2,1), confusionMatrix(2,2), confusionMatrix(2,3), confusionMatrix(3,1), confusionMatrix(3,2), confusionMatrix(3,3), 0, 0, 0, confusionMatrix(4,4)); Dawn@4: end Dawn@4: Dawn@4: Dawn@4: Dawn@4: end Dawn@4: Dawn@4: function [idx] = groupFind( groupNames, str ) Dawn@4: Dawn@4: idx = 0; Dawn@4: for( i=1: length( groupNames ) ) Dawn@4: if( ~isempty(strfind( groupNames(i,:), str(1) )) && ~isempty(strfind( groupNames(i,:), str(2) ))) Dawn@4: idx = i; Dawn@4: end Dawn@4: end Dawn@4: end