Dawn@4: function [] = kmeans_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( 'kmeans_paper_SingingFormantsStats.txt', 'a' ); Dawn@4: % input results file name Dawn@4: % inputFileName = 'paper_singingFormantsStats_ZhangShuo.txt'; Dawn@4: % inputFileName = 'paper_singingFormantsStats_WangXinnong.txt'; 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: while( ~(feof(inputFileID)) ) Dawn@4: Dawn@4: outputValues = []; Dawn@4: % sampleEmotion = []; Dawn@4: % gender = []; 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: elseif( ~(isempty(strfind(thestr,'neg')))) Dawn@4: % sample is negative Dawn@4: sampleEmotion( fileCount ) = 'N'; 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: % ------------ apply the k-means classifier ------------------------ Dawn@4: Dawn@4: noOfClusters = 2; % we are only trying to identify positive and negative emotions Dawn@4: Dawn@4: Dawn@4: [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: 'start', 'sample', 'Distance', 'cityblock'); Dawn@4: Dawn@4: %display results grouped by emotion Dawn@4: fprintf( masterFileOutputID, '\n Emotion grouping \n'); Dawn@4: fprintf( masterFileOutputID, 'cityblock \n'); Dawn@4: [ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); Dawn@4: [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'cityblock' ); Dawn@4: Dawn@4: Dawn@4: fprintf( masterFileOutputID, 'sqEuclidean \n'); Dawn@4: [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: 'start', 'sample', 'Distance', 'sqEuclidean'); Dawn@4: Dawn@4: [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); Dawn@4: [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'sqEuclidean' ); Dawn@4: Dawn@4: Dawn@4: fprintf( masterFileOutputID, 'cosine \n'); Dawn@4: [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: 'start', 'sample', 'Distance', 'cosine'); Dawn@4: Dawn@4: [ groupStats, groupNames ] = processKMeansResults( 'cosine', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); Dawn@4: [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID,'cosine' ); Dawn@4: Dawn@4: Dawn@4: fprintf( masterFileOutputID, 'correlation \n'); Dawn@4: [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: 'start', 'sample', 'Distance', 'correlation'); Dawn@4: Dawn@4: [ groupStats, groupNames ] = processKMeansResults( 'correlation', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); Dawn@4: [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID, 'correlation' ); Dawn@4: 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: %-------------------------------------------------------------------