Dawn@4: function [] = SVM_Formants_Singing( varargin ) Dawn@4: Dawn@4: cd 'C:\Users\dawn\Dropbox\TestResults' Dawn@4: Dawn@4: DEBUG = 0; Dawn@4: % output results file name Dawn@4: masterFileOutputID = fopen( 'SVM_paper_SingingFormantsStats.txt', 'a' ); Dawn@4: % input results file name Dawn@4: inputFileName = 'paper_singingFormantsStats.txt'; Dawn@4: Dawn@4: % This function allows the user to stipulate which Singing voice LLD's they Dawn@4: % wish to forward to a k-means classifier and produces a file of Dawn@4: % performance characteristics. Input arguments stipulate the LLD's and Dawn@4: % there is a choice of:- Dawn@4: % Dawn@4: % ---- PRAAT FORMANT MEASUREMENTS ---- Dawn@4: % '_Formant_Burg' Dawn@4: % '_Formant_all' Dawn@4: % '_Formant_robust' Dawn@4: % Dawn@4: % A text file entitled kmeans_Singing_LLD1name_LLD2name_ ... LLDNname.txt Dawn@4: % is produced that contains the results of the k-mean classification for Dawn@4: % the LLD's specified and named in the result document title. Dawn@4: Dawn@4: fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); Dawn@4: inputFileID = fopen( inputFileName ); Dawn@4: Dawn@4: % get the column numbers of the results that we want to classify Dawn@4: Dawn@4: % COLUMN NUMBER : METRIC Dawn@4: % Dawn@4: % ------------- BURG FORMANTS --------------- Dawn@4: % 11 : Number of BURG formants listed = nBF Dawn@4: % Dawn@4: % THERE ARE CURRENTLY 24 MEASUREMENTS TAKEN FOR EACH FORMANT Dawn@4: nMetrics = 24; Dawn@4: % Dawn@4: % 12 : mean frequency of the first BURG formant Dawn@4: % 13 : variance of the first BURG formant Dawn@4: % 14 : minimum frequency of the first BURG formant Dawn@4: % 15 : maximum frequency of the first BURG formant Dawn@4: % 16 : mean Frequency Derivative of the first BURG formant Dawn@4: % 17 : varience of the Frequency Derivative of the first BURG formant Dawn@4: % 18 : min of the Frequency Derivative of the first BURG formant Dawn@4: % 19 : max of the Frequency Derivative of the first BURG formant Dawn@4: % 20 : mean of the Frequency 2nd Derivative of the first BURG formant Dawn@4: % 21 : varience of the Frequency 2nd Derivative of the first BURG formant Dawn@4: % 22 : min of the Frequency 2nd Derivative of the first BURG formant Dawn@4: % 23 : max of the Frequency 2nd Derivative of the first BURG formant Dawn@4: % 24 : mean of the Bandwidth of the first BURG formant Dawn@4: % 25 : varience of the Bandwidth of the first BURG formant Dawn@4: % 26 : min of the Bandwidth of the first BURG formant Dawn@4: % 27 : max of the Bandwidth of the first BURG formant Dawn@4: % 28 : mean of the Bandwidth Derivative of the first BURG formant Dawn@4: % 29 : varience of the Bandwidth Derivative of the first BURG formant Dawn@4: % 30 : min of the Bandwidth Derivative of the first BURG formant Dawn@4: % 31 : max of the Bandwidth Derivative of the first BURG formant Dawn@4: % 32 : mean of the Bandwidth 2nd Derivative of the first BURG formant Dawn@4: % 33 : var of the Bandwidth 2nd Derivative of the first BURG formant Dawn@4: % 34 : min of the Bandwidth 2nd Derivative of the first BURG formant Dawn@4: % 35 : max of the Bandwidth 2nd Derivative of the first BURG formant Dawn@4: % Dawn@4: % ....... there are nMetrics for each formant in nBF formants, so cycle Dawn@4: % through until the last is reached ...... Dawn@4: % Dawn@4: % 36 + ((nBF-1)*nMetrics) : mean frequency of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 1 : variance of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 2 : minimum frequency of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 3 : maximum frequency of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 4 : mean Frequency Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 5 : varience of the Frequency Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 6 : min of the Frequency Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 7 : max of the Frequency Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 8 : mean of the Frequency 2nd Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 9 : varience of the Frequency 2nd Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 10 : min of the Frequency 2nd Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 11 : max of the Frequency 2nd Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 12 : mean of the Bandwidth of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 13 : varience of the Bandwidth of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 14 : min of the Bandwidth of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 15 : max of the Bandwidth of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 16 : mean of the Bandwidth Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 17 : variece of the Bandwidth Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 18 : min of the Bandwidth Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 19 : max of the Bandwidth Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 20 : mean of the Bandwidth 2nd Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 21 : var of the Bandwidth 2nd Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 22 : min of the Bandwidth 2nd Derivative of the nBF BURG formant Dawn@4: % 36 + ((nBF-1)*nMetrics) + 23 : max of the Bandwidth 2nd Derivative of the nBF BURG formant Dawn@4: % Dawn@4: % FOR THE MEAN OF ALL BURG FORMANTS Dawn@4: % 36 + (nBF*nMetrics) : mean of all formants Frequency Dawn@4: % 36 + (nBF*nMetrics) + 1 : varience of the mean of all formants Frequency Dawn@4: % 36 + (nBF*nMetrics) + 2 : minimum of the mean of all formants Frequency Dawn@4: % 36 + (nBF*nMetrics) + 3 : maximum of the mean of all formants Frequency Dawn@4: % 36 + (nBF*nMetrics) + 4 : mean of all formants mean Frequency Derivative Dawn@4: % 36 + (nBF*nMetrics) + 5 : mean of all formants varience Frequency Derivative Dawn@4: % 36 + (nBF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative Dawn@4: % 36 + (nBF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative Dawn@4: % 36 + (nBF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative Dawn@4: % 36 + (nBF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative Dawn@4: % 36 + (nBF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative Dawn@4: % 36 + (nBF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative Dawn@4: % Dawn@4: % ------------- ALL FORMANTS --------------- Dawn@4: % Dawn@4: % 36 + (nBF*nMetrics) + 12 : Number of ALL formants listed = nAF Dawn@4: % Dawn@4: % startOfALLMeasurements = 36 + (nBF*nMetrics) + 13; Dawn@4: % Dawn@4: % startOfALLMeasurements : mean frequency of the first ALL formant Dawn@4: % startOfALLMeasurements + 1 : variance of the first ALL formant Dawn@4: % startOfALLMeasurements + 2 : minimum frequency of the first ALL formant Dawn@4: % startOfALLMeasurements + 3 : maximum frequency of the first ALL formant Dawn@4: % startOfALLMeasurements + 4 : mean Frequency Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 5 : varience of the Frequency Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 6 : min of the Frequency Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 7 : max of the Frequency Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 10 : min of the Frequency 2nd Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 11 : max of the Frequency 2nd Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 12 : mean of the Bandwidth of the first ALL formant Dawn@4: % startOfALLMeasurements + 13 : varience of the Bandwidth of the first ALL formant Dawn@4: % startOfALLMeasurements + 14 : min of the Bandwidth of the first ALL formant Dawn@4: % startOfALLMeasurements + 15 : max of the Bandwidth of the first ALL formant Dawn@4: % startOfALLMeasurements + 16 : mean of the Bandwidth Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 17 : varience of the Bandwidth Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 18 : min of the Bandwidth Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 19 : max of the Bandwidth Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ALL formant Dawn@4: % startOfALLMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ALL formant Dawn@4: % Dawn@4: % ....... there are nMetrics for each formant in nAF formants, so cycle Dawn@4: % through until the last is reached ...... Dawn@4: % Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean frequency of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : variance of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : minimum frequency of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : maximum frequency of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean Frequency Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Bandwidth of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : variece of the Bandwidth Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nAF ALL formant Dawn@4: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nAF ALL formant Dawn@4: % Dawn@4: % FOR THE MEAN OF ALL ALL FORMANTS Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) : mean of all formants Frequency Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 1 : varience of the mean of all formants Frequency Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 2 : minimum of the mean of all formants Frequency Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 3 : maximum of the mean of all formants Frequency Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 4 : mean of all formants mean Frequency Derivative Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 5 : mean of all formants varience Frequency Derivative Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative Dawn@4: % Dawn@4: % ------------- ROBUST FORMANTS --------------- Dawn@4: % Dawn@4: % startOfALLMeasurements + (nAF*nMetrics) + 12 : Number of ROBUST formants listed = nRF Dawn@4: % Dawn@4: % startOfROBUSTMeasurements = startOfALLMeasurements + (nAF*nMetrics) + 13; Dawn@4: % Dawn@4: % startOfROBUSTMeasurements : mean frequency of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 1 : variance of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 2 : minimum frequency of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 3 : maximum frequency of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 4 : mean Frequency Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 5 : varience of the Frequency Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 6 : min of the Frequency Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 7 : max of the Frequency Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 10 : min of the Frequency 2nd Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 11 : max of the Frequency 2nd Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 12 : mean of the Bandwidth of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 13 : varience of the Bandwidth of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 14 : min of the Bandwidth of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 15 : max of the Bandwidth of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 16 : mean of the Bandwidth Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 17 : varience of the Bandwidth Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 18 : min of the Bandwidth Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 19 : max of the Bandwidth Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ROBUST formant Dawn@4: % startOfROBUSTMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ROBUST formant Dawn@4: % Dawn@4: % ....... there are nMetrics for each formant in nRF formants, so cycle Dawn@4: % through until the last is reached ...... Dawn@4: % Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean frequency of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variance of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : minimum frequency of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : maximum frequency of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean Frequency Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Bandwidth of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variece of the Bandwidth Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nRF ROBUST formant Dawn@4: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nRF ROBUST formant Dawn@4: % Dawn@4: % FOR THE MEAN OF ALL ROBUST FORMANTS Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) : mean of all formants Frequency Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 1 : varience of the mean of all formants Frequency Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 2 : minimum of the mean of all formants Frequency Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 3 : maximum of the mean of all formants Frequency Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 4 : mean of all formants mean Frequency Derivative Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 5 : mean of all formants varience Frequency Derivative Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative Dawn@4: % startOfROBUSTMeasurements + (nRF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative Dawn@4: % Dawn@4: Dawn@4: noOfArguments = length(varargin); Dawn@4: columnIndices = []; Dawn@4: Dawn@4: getBURGFormants = 0; Dawn@4: getAllFormants=0; Dawn@4: getRobustFormants=0; Dawn@4: Dawn@4: for i=1 : noOfArguments Dawn@4: if( strcmp( varargin{i}, 'formant_Burg' )) Dawn@4: getBURGFormants = 1; Dawn@4: elseif( strcmp( varargin{i}, 'formant_all' )) Dawn@4: getAllFormants=1; Dawn@4: elseif( strcmp( varargin{i}, 'formant_robust' )) Dawn@4: getRobustFormants=1; Dawn@4: end Dawn@4: end Dawn@4: Dawn@4: titleName = ''; Dawn@4: for i=1 : noOfArguments Dawn@4: titleName = [ titleName varargin{i} '_']; Dawn@4: fprintf( masterFileOutputID, '%s_', varargin{i} ); Dawn@4: end Dawn@4: Dawn@4: fprintf( masterFileOutputID, '\t' ); Dawn@4: Dawn@4: % -------------------- get the data from the results file --------------- Dawn@4: lineCount = 0; Dawn@4: fileCount = 0; Dawn@4: data = []; Dawn@4: groups = []; Dawn@4: Dawn@4: while( ~(feof(inputFileID)) ) Dawn@4: Dawn@4: outputValues = []; Dawn@4: Dawn@4: thestr = fgetl(inputFileID); Dawn@4: if( lineCount > 10 ) % skip the file header Dawn@4: fileCount = fileCount + 1; Dawn@4: Dawn@4: % determine whether we have a positive or negative sample Dawn@4: sampleEmotion( fileCount ) = 'U'; Dawn@4: if( ~(isempty(strfind(thestr,'pos')))) Dawn@4: % sample is positive Dawn@4: sampleEmotion( fileCount ) = 'P'; Dawn@4: groups( fileCount ) = 1; Dawn@4: elseif( ~(isempty(strfind(thestr,'neg')))) Dawn@4: % sample is negative Dawn@4: sampleEmotion( fileCount ) = 'N'; Dawn@4: groups( fileCount ) = 0; Dawn@4: else Dawn@4: disp('EEEK!'); Dawn@4: pause; Dawn@4: end Dawn@4: Dawn@4: % % determine whether we have a male, female or trans sample Dawn@4: % gender( fileCount ) = '?'; Dawn@4: % if( ~(isempty(strfind(thestr,'fem')))) Dawn@4: % % gender is female Dawn@4: % gender( fileCount ) = 'F'; Dawn@4: % elseif( ~(isempty(strfind(thestr,'male')))) Dawn@4: % % gender is male Dawn@4: % gender( fileCount ) = 'M'; Dawn@4: % elseif( ~(isempty(strfind(thestr,'trans')))) Dawn@4: % % gender is trans Dawn@4: % gender( fileCount ) = 'T'; Dawn@4: % else Dawn@4: % disp('EEEK!'); Dawn@4: % pause; Dawn@4: % end Dawn@4: Dawn@4: %how many values are in the string? Dawn@4: spaces = strfind( thestr, ' ' ); Dawn@4: numberstr = thestr( spaces(1) : end ); % chop off the file name Dawn@4: frmtpos = strfind( numberstr, 'maxNoOfFormants'); % find the position of the label for number of formants Dawn@4: Dawn@4: % str1 = numberstr( 1 : frmtpos(1)-1 ); % string contains jitter and shimmer values Dawn@4: str2 = numberstr( frmtpos(1) : frmtpos(2)-1 ); % string contains all BURG formant information Dawn@4: str3 = numberstr( frmtpos(2) : frmtpos(3)-1 ); % string contains all ALL formant information Dawn@4: str4 = numberstr( frmtpos(3) : end ); % string contains all ROBUST formant information Dawn@4: Dawn@4: Dawn@4: % vars = sscanf( str1, '%f', inf ); Dawn@4: % % extract the shimmer and jitter values Dawn@4: % outputValues = [ outputValues vars( columnIndices )']; Dawn@4: Dawn@4: if( getBURGFormants ) Dawn@4: spaces = strfind( str2, ' ' ); % remove the string 'maxNoOfFormants' Dawn@4: vars = sscanf( str2( spaces(1) : end ), '%f', inf ); Dawn@4: outputValues = stripOutFormantValues( vars, outputValues ); Dawn@4: end Dawn@4: Dawn@4: if( getAllFormants ) Dawn@4: spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants' Dawn@4: vars = sscanf( str3( spaces(1) : end ), '%f', inf ); Dawn@4: outputValues = stripOutFormantValues( vars, outputValues ); Dawn@4: end Dawn@4: Dawn@4: if( getRobustFormants ) Dawn@4: spaces = strfind( str4, ' ' ); % remove the string 'maxNoOfFormants' Dawn@4: vars = sscanf( str4( spaces(1) : end ), '%f', inf ); Dawn@4: outputValues = stripOutFormantValues( vars, outputValues ); Dawn@4: end Dawn@4: Dawn@4: [m n] = size( data ); Dawn@4: % sometimes the 'all' formants command gives us fewer formants than Dawn@4: % usual. If this is the case,then we will have to pad with zeros Dawn@4: % for now. Dawn@4: if( n > length( outputValues ) ) Dawn@4: lenDiff = n - length( outputValues ); Dawn@4: outputValues = [ outputValues zeros( 1, lenDiff ) ]; Dawn@4: elseif( n < length( outputValues ) ) Dawn@4: lenDiff = length( outputValues ) - n; Dawn@4: outputValues = [ outputValues zeros( 1, lenDiff ) ]; Dawn@4: end Dawn@4: Dawn@4: data( fileCount, : ) = outputValues; Dawn@4: Dawn@4: end Dawn@4: lineCount = lineCount + 1; Dawn@4: Dawn@4: end Dawn@4: fclose(inputFileID); Dawn@4: Dawn@4: Dawn@4: Dawn@4: % ------------ apply the SVM classifier ------------------------ Dawn@4: Dawn@4: resultMatrix = []; Dawn@4: Dawn@4: noOfIterations = 10; Dawn@4: Dawn@4: for n = 1:noOfIterations Dawn@4: % Randomly select training and test sets, perhaps we should try all and Dawn@4: % choose the best? Dawn@4: [train, test] = crossvalind('holdOut',groups); Dawn@4: cp = classperf(groups); Dawn@4: Dawn@4: % Use a linear support vector machine classifier Dawn@4: svmStruct = svmtrain(data(train,:),groups(train)); Dawn@4: classes = svmclassify(svmStruct,data(test,:)); Dawn@4: % See how well the classifier performed Dawn@4: classperf(cp,classes,test); Dawn@4: numbers = cp.CountingMatrix; Dawn@4: Dawn@4: resultMatrix (n,:,:) = cp.DiagnosticTable; Dawn@4: % Dawn@4: end Dawn@4: Dawn@4: Dawn@4: 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: Dawn@4: % takes the average of 10 iterations - do we want to take the best? Dawn@4: Dawn@4: meanResults(1,1) = mean( resultMatrix(:,1,1) ); Dawn@4: meanResults(1,2) = mean( resultMatrix(:,2,1) ); Dawn@4: meanResults(2,1) = mean( resultMatrix(:,1,2) ); Dawn@4: meanResults(2,2) = mean( resultMatrix(:,2,2) ); Dawn@4: Dawn@4: meanResults(3,:)=0; Dawn@4: meanResults(:,3)=0; Dawn@4: Dawn@4: meanResults(3,3) = (meanResults(1,1) + meanResults(2,2));% / sum(sum(meanResults)); Dawn@4: Dawn@4: % convert to percentages Dawn@4: % how many of each sample do we have? Dawn@4: groupNumbers = unique( groups( test )); Dawn@4: groupNames = unique( sampleEmotion( test )); Dawn@4: sampleEmotionTest = sampleEmotion( test ); Dawn@4: % which group is which emotion? Dawn@4: thisGroupNumber = groupNumbers(1); Dawn@4: thisGroup = find( groups( test ) == thisGroupNumber ); Dawn@4: thisGroupName = unique( sampleEmotionTest( thisGroup )); Dawn@4: Dawn@4: thatGroupNumber = groupNumbers(2); Dawn@4: thatGroup = find( groups( test ) == thatGroupNumber ); Dawn@4: thatGroupName = unique( sampleEmotionTest( thatGroup )); Dawn@4: Dawn@4: if(length( thisGroupName ) ~= 1 ) Dawn@4: disp('ARGH!'); Dawn@4: pause; Dawn@4: end Dawn@4: Dawn@4: thisGroupNumberOfSamples = length( thisGroup ); Dawn@4: thatGroupNumberOfSamples = length( thatGroup ); Dawn@4: Dawn@4: if( thisGroupName == 'P' ) Dawn@4: %swap all the variables ready for checking Dawn@4: temp = thisGroupNumberOfSamples; Dawn@4: thisGroupNumberOfSamples = thatGroupNumberOfSamples; Dawn@4: thatGroupNumberOfSamples = temp; Dawn@4: Dawn@4: temp = thisGroupName; Dawn@4: thisGroupName = thatGroupName Dawn@4: thatGroupName = temp; Dawn@4: disp('CHECK ME!'); Dawn@4: end Dawn@4: Dawn@4: if( thisGroupName == 'N' ) Dawn@4: % group 0 is negative Dawn@4: if( sum( meanResults(1,:) ) == thisGroupNumberOfSamples ) Dawn@4: %if the elements in the first row add up to the number of negative Dawn@4: %samples, then swap the rows because we want the top row to be the Dawn@4: %results for the positive samples Dawn@4: temp(:,1) = meanResults(1:2,2); Dawn@4: temp(:,2) = meanResults(1:2,1); Dawn@4: temp2(1,:) = temp(2,:); Dawn@4: temp2(2,:) = temp(1,:); Dawn@4: Dawn@4: meanResults(1:2,1) = temp2(:,1); Dawn@4: meanResults(1:2,2) = temp2(:,2); Dawn@4: Dawn@4: % check the number of positive samples Dawn@4: if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ... Dawn@4: && ( thatGroupName == 'P' ) ) Dawn@4: % row 1 is positive Dawn@4: disp('matrix correct'); Dawn@4: else Dawn@4: disp('ARGH!'); Dawn@4: pause; Dawn@4: end Dawn@4: Dawn@4: elseif( sum( meanResults(2,:) ) == thisGroupNumberOfSamples ) Dawn@4: Dawn@4: % the elements in the second row add up to the number of negative Dawn@4: % samples, so the matrix is the correct way around Dawn@4: Dawn@4: % check the number of positive samples Dawn@4: if(( sum( meanResults(1,:) ) == thatGroupNumberOfSamples ) ... Dawn@4: && ( thatGroupName == 'P' ) ) Dawn@4: % row 0 is positive Dawn@4: disp('matrix correct'); Dawn@4: else Dawn@4: disp('ARGH!'); Dawn@4: pause; Dawn@4: end Dawn@4: end Dawn@4: end Dawn@4: Dawn@4: % calculate the percentages Dawn@4: numberOfSamples = sum(sum( meanResults(1:2,1:2))); Dawn@4: percentageResults = meanResults; Dawn@4: percentageResults(1,1) = meanResults(1,1) / numberOfSamples; Dawn@4: percentageResults(1,2) = meanResults(1,2) / numberOfSamples; Dawn@4: percentageResults(2,1) = meanResults(2,1) / numberOfSamples; Dawn@4: percentageResults(2,2) = meanResults(2,2) / numberOfSamples; Dawn@4: percentageResults(3,3) = meanResults(3,3) / numberOfSamples; Dawn@4: Dawn@4: percentageResults = percentageResults * 100 Dawn@4: Dawn@4: confusionMatrix = percentageResults; 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: Dawn@4: % print latex results to the screen Dawn@4: str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(1,1), percentageResults(1,2) ); Dawn@4: disp(str1); Dawn@4: str1 = sprintf(' & %2.2f & %2.2f & \\\\', percentageResults(2,1), percentageResults(2,2) ); Dawn@4: disp(str1); Dawn@4: str1 = sprintf(' & & & %2.2f \\\\',percentageResults(3,3) ); Dawn@4: disp(str1); Dawn@4: Dawn@4: fprintf( masterFileOutputID, '\n' ); Dawn@4: fclose( masterFileOutputID ); Dawn@4: Dawn@4: end Dawn@4: Dawn@4: %------------------------------------------------------------------ Dawn@4: Dawn@4: function [ outputValues ] = stripOutFormantValues( vars, outputValues ) Dawn@4: Dawn@4: noOfFormantValues = length( vars ) - 1; % gives the number of formant arguments only Dawn@4: noOfFormants = vars(1); Dawn@4: % there are 12 measurements for the mean of all formants (so the number Dawn@4: % of formants is not important) for each formant measurement. Dawn@4: if( noOfFormants ~= (noOfFormantValues-12)/24 ) Dawn@4: disp('EEK!'); Dawn@4: pause; Dawn@4: else Dawn@4: outputValues = [ outputValues vars( 2:end )' ]; Dawn@4: end Dawn@4: Dawn@4: end Dawn@4: Dawn@4: %-------------------------------------------------------------------