Dawn@4: function [] = kmeans_PRAAT_Singing( varargin ) dawn@2: dawn@2: cd 'C:\Users\dawn\Dropbox\TestResults' dawn@2: Dawn@4: DEBUG = 0; dawn@2: % output results file name Dawn@4: masterFileOutputID = fopen( 'kmeans_Singing_PRAAT.txt', 'a' ); dawn@2: % input results file name dawn@2: inputFileName = 'singingPRAATStats.txt'; dawn@2: dawn@2: % This function allows the user to stipulate which Singing voice LLD's they dawn@2: % wish to forward to a k-means classifier and produces a file of dawn@2: % performance characteristics. Input arguments stipulate the LLD's and dawn@2: % there is a choice of:- dawn@2: % dawn@2: % ---- PRAAT JITTER MEASUREMENTS ---- dawn@2: % '_jitter_ddp' dawn@2: % '_jitter_local' dawn@2: % '_jitter_ppq5' dawn@2: % '_jitter_rap' dawn@2: % ---- PRAAT SHIMMER MEASUREMENTS ---- dawn@2: % '_shimmer_local' dawn@2: % '_shimmer_dda' dawn@2: % '_shimmer_apq3' dawn@2: % '_shimmer_apq5' dawn@2: % '_shimmer_apq11' dawn@2: % ---- PRAAT FORMANT MEASUREMENTS ---- dawn@2: % '_Formant_Burg' dawn@2: % '_Formant_all' dawn@2: % '_Formant_robust' dawn@2: % dawn@2: % A text file entitled kmeans_Singing_LLD1name_LLD2name_ ... LLDNname.txt dawn@2: % is produced that contains the results of the k-mean classification for dawn@2: % the LLD's specified and named in the result document title. dawn@2: dawn@2: fprintf( masterFileOutputID, '\n RESULTS FILE NAME: %s\n', inputFileName); dawn@2: inputFileID = fopen( inputFileName ); dawn@2: dawn@2: % get the column numbers of the results that we want to classify dawn@2: dawn@2: % COLUMN NUMBER : METRIC dawn@2: % 1 : audio file name dawn@2: % 2 : jitter ddp dawn@2: % 3 : jitter local dawn@2: % 4 : jitter ppq5 dawn@2: % 5 : jitter rap dawn@2: % 6 : shimmer local dawn@2: % 7 : shimmer dda dawn@2: % 8 : shimmer apq3 dawn@2: % 9 : shimmer apq5 dawn@2: % 10 : shimmer apq11 dawn@2: % dawn@2: % ------------- BURG FORMANTS --------------- dawn@2: % 11 : Number of BURG formants listed = nBF dawn@2: % dawn@2: % THERE ARE CURRENTLY 24 MEASUREMENTS TAKEN FOR EACH FORMANT dawn@2: nMetrics = 24; dawn@2: % dawn@2: % 12 : mean frequency of the first BURG formant dawn@2: % 13 : variance of the first BURG formant dawn@2: % 14 : minimum frequency of the first BURG formant dawn@2: % 15 : maximum frequency of the first BURG formant dawn@2: % 16 : mean Frequency Derivative of the first BURG formant dawn@2: % 17 : varience of the Frequency Derivative of the first BURG formant dawn@2: % 18 : min of the Frequency Derivative of the first BURG formant dawn@2: % 19 : max of the Frequency Derivative of the first BURG formant dawn@2: % 20 : mean of the Frequency 2nd Derivative of the first BURG formant dawn@2: % 21 : varience of the Frequency 2nd Derivative of the first BURG formant dawn@2: % 22 : min of the Frequency 2nd Derivative of the first BURG formant dawn@2: % 23 : max of the Frequency 2nd Derivative of the first BURG formant dawn@2: % 24 : mean of the Bandwidth of the first BURG formant dawn@2: % 25 : varience of the Bandwidth of the first BURG formant dawn@2: % 26 : min of the Bandwidth of the first BURG formant dawn@2: % 27 : max of the Bandwidth of the first BURG formant dawn@2: % 28 : mean of the Bandwidth Derivative of the first BURG formant dawn@2: % 29 : varience of the Bandwidth Derivative of the first BURG formant dawn@2: % 30 : min of the Bandwidth Derivative of the first BURG formant dawn@2: % 31 : max of the Bandwidth Derivative of the first BURG formant dawn@2: % 32 : mean of the Bandwidth 2nd Derivative of the first BURG formant dawn@2: % 33 : var of the Bandwidth 2nd Derivative of the first BURG formant dawn@2: % 34 : min of the Bandwidth 2nd Derivative of the first BURG formant dawn@2: % 35 : max of the Bandwidth 2nd Derivative of the first BURG formant dawn@2: % dawn@2: % ....... there are nMetrics for each formant in nBF formants, so cycle dawn@2: % through until the last is reached ...... dawn@2: % dawn@2: % 36 + ((nBF-1)*nMetrics) : mean frequency of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 1 : variance of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 2 : minimum frequency of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 3 : maximum frequency of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 4 : mean Frequency Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 5 : varience of the Frequency Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 6 : min of the Frequency Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 7 : max of the Frequency Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 8 : mean of the Frequency 2nd Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 9 : varience of the Frequency 2nd Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 10 : min of the Frequency 2nd Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 11 : max of the Frequency 2nd Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 12 : mean of the Bandwidth of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 13 : varience of the Bandwidth of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 14 : min of the Bandwidth of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 15 : max of the Bandwidth of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 16 : mean of the Bandwidth Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 17 : variece of the Bandwidth Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 18 : min of the Bandwidth Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 19 : max of the Bandwidth Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 20 : mean of the Bandwidth 2nd Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 21 : var of the Bandwidth 2nd Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 22 : min of the Bandwidth 2nd Derivative of the nBF BURG formant dawn@2: % 36 + ((nBF-1)*nMetrics) + 23 : max of the Bandwidth 2nd Derivative of the nBF BURG formant dawn@2: % dawn@2: % FOR THE MEAN OF ALL BURG FORMANTS dawn@2: % 36 + (nBF*nMetrics) : mean of all formants Frequency dawn@2: % 36 + (nBF*nMetrics) + 1 : varience of the mean of all formants Frequency dawn@2: % 36 + (nBF*nMetrics) + 2 : minimum of the mean of all formants Frequency dawn@2: % 36 + (nBF*nMetrics) + 3 : maximum of the mean of all formants Frequency dawn@2: % 36 + (nBF*nMetrics) + 4 : mean of all formants mean Frequency Derivative dawn@2: % 36 + (nBF*nMetrics) + 5 : mean of all formants varience Frequency Derivative dawn@2: % 36 + (nBF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative dawn@2: % 36 + (nBF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative dawn@2: % 36 + (nBF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative dawn@2: % 36 + (nBF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative dawn@2: % 36 + (nBF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative dawn@2: % 36 + (nBF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative dawn@2: % dawn@2: % ------------- ALL FORMANTS --------------- dawn@2: % dawn@2: % 36 + (nBF*nMetrics) + 12 : Number of ALL formants listed = nAF dawn@2: % dawn@2: % startOfALLMeasurements = 36 + (nBF*nMetrics) + 13; dawn@2: % dawn@2: % startOfALLMeasurements : mean frequency of the first ALL formant dawn@2: % startOfALLMeasurements + 1 : variance of the first ALL formant dawn@2: % startOfALLMeasurements + 2 : minimum frequency of the first ALL formant dawn@2: % startOfALLMeasurements + 3 : maximum frequency of the first ALL formant dawn@2: % startOfALLMeasurements + 4 : mean Frequency Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 5 : varience of the Frequency Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 6 : min of the Frequency Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 7 : max of the Frequency Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 10 : min of the Frequency 2nd Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 11 : max of the Frequency 2nd Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 12 : mean of the Bandwidth of the first ALL formant dawn@2: % startOfALLMeasurements + 13 : varience of the Bandwidth of the first ALL formant dawn@2: % startOfALLMeasurements + 14 : min of the Bandwidth of the first ALL formant dawn@2: % startOfALLMeasurements + 15 : max of the Bandwidth of the first ALL formant dawn@2: % startOfALLMeasurements + 16 : mean of the Bandwidth Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 17 : varience of the Bandwidth Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 18 : min of the Bandwidth Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 19 : max of the Bandwidth Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ALL formant dawn@2: % startOfALLMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ALL formant dawn@2: % dawn@2: % ....... there are nMetrics for each formant in nAF formants, so cycle dawn@2: % through until the last is reached ...... dawn@2: % dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean frequency of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : variance of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : minimum frequency of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : maximum frequency of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean Frequency Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : varience of the Bandwidth of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : variece of the Bandwidth Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nAF ALL formant dawn@2: % startOfALLMeasurements + ((nAF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nAF ALL formant dawn@2: % dawn@2: % FOR THE MEAN OF ALL ALL FORMANTS dawn@2: % startOfALLMeasurements + (nAF*nMetrics) : mean of all formants Frequency dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 1 : varience of the mean of all formants Frequency dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 2 : minimum of the mean of all formants Frequency dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 3 : maximum of the mean of all formants Frequency dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 4 : mean of all formants mean Frequency Derivative dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 5 : mean of all formants varience Frequency Derivative dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative dawn@2: % dawn@2: % ------------- ROBUST FORMANTS --------------- dawn@2: % dawn@2: % startOfALLMeasurements + (nAF*nMetrics) + 12 : Number of ROBUST formants listed = nRF dawn@2: % dawn@2: % startOfROBUSTMeasurements = startOfALLMeasurements + (nAF*nMetrics) + 13; dawn@2: % dawn@2: % startOfROBUSTMeasurements : mean frequency of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 1 : variance of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 2 : minimum frequency of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 3 : maximum frequency of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 4 : mean Frequency Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 5 : varience of the Frequency Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 6 : min of the Frequency Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 7 : max of the Frequency Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 8 : mean of the Frequency 2nd Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 9 : varience of the Frequency 2nd Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 10 : min of the Frequency 2nd Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 11 : max of the Frequency 2nd Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 12 : mean of the Bandwidth of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 13 : varience of the Bandwidth of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 14 : min of the Bandwidth of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 15 : max of the Bandwidth of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 16 : mean of the Bandwidth Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 17 : varience of the Bandwidth Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 18 : min of the Bandwidth Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 19 : max of the Bandwidth Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 20 : mean of the Bandwidth 2nd Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 21 : var of the Bandwidth 2nd Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 22 : min of the Bandwidth 2nd Derivative of the first ROBUST formant dawn@2: % startOfROBUSTMeasurements + 23 : max of the Bandwidth 2nd Derivative of the first ROBUST formant dawn@2: % dawn@2: % ....... there are nMetrics for each formant in nRF formants, so cycle dawn@2: % through until the last is reached ...... dawn@2: % dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean frequency of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variance of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : minimum frequency of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : maximum frequency of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean Frequency Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Frequency 2nd Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Frequency 2nd Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Frequency 2nd Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Frequency 2nd Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : varience of the Bandwidth of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : variece of the Bandwidth Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : mean of the Bandwidth 2nd Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : var of the Bandwidth 2nd Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : min of the Bandwidth 2nd Derivative of the nRF ROBUST formant dawn@2: % startOfROBUSTMeasurements + ((nRF-1)*nMetrics) : max of the Bandwidth 2nd Derivative of the nRF ROBUST formant dawn@2: % dawn@2: % FOR THE MEAN OF ALL ROBUST FORMANTS dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) : mean of all formants Frequency dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 1 : varience of the mean of all formants Frequency dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 2 : minimum of the mean of all formants Frequency dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 3 : maximum of the mean of all formants Frequency dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 4 : mean of all formants mean Frequency Derivative dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 5 : mean of all formants varience Frequency Derivative dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 6 : min of the mean of all formants Frequency Derivative dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 7 : max of the mean of all formants Frequency Derivative dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 8 : mean of the mean of all formants Frequency 2nd Derivative dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 9 : varience of the mean of all formants Frequency 2nd Derivative dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 10 : min of the mean of all formants Frequency 2nd Derivative dawn@2: % startOfROBUSTMeasurements + (nRF*nMetrics) + 11 : max of the mean of all formants Frequency 2nd Derivative dawn@2: % dawn@2: dawn@2: noOfArguments = length(varargin); dawn@2: columnIndices = []; dawn@2: dawn@2: getBURGFormants = 0; Dawn@4: getAllFormants=0; dawn@2: getRobustFormants=0; dawn@2: dawn@2: for i=1 : noOfArguments dawn@2: if( strcmp( varargin{i}, 'jitter_ddp' )) dawn@2: columnIndices = [columnIndices 1]; dawn@2: elseif( strcmp( varargin{i}, 'jitter_local' )) dawn@2: columnIndices = [columnIndices 2]; dawn@2: elseif( strcmp( varargin{i}, 'jitter_ppq5' )) dawn@2: columnIndices = [columnIndices 3]; dawn@2: elseif( strcmp( varargin{i}, 'jitter_rap' )) dawn@2: columnIndices = [columnIndices 4]; dawn@2: elseif( strcmp( varargin{i}, 'shimmer_local' )) dawn@2: columnIndices = [columnIndices 5]; dawn@2: elseif( strcmp( varargin{i}, 'shimmer_dda' )) dawn@2: columnIndices = [columnIndices 6]; dawn@2: elseif( strcmp( varargin{i}, 'shimmer_apq3' )) dawn@2: columnIndices = [columnIndices 7]; dawn@2: elseif( strcmp( varargin{i}, 'shimmer_apq5' )) dawn@2: columnIndices = [columnIndices 8]; dawn@2: elseif( strcmp( varargin{i}, 'shimmer_apq11' )) dawn@2: columnIndices = [columnIndices 9]; dawn@2: elseif( strcmp( varargin{i}, 'formant_Burg' )) dawn@2: getBURGFormants = 1; dawn@2: elseif( strcmp( varargin{i}, 'formant_all' )) Dawn@4: getAllFormants=1; dawn@2: elseif( strcmp( varargin{i}, 'formant_robust' )) dawn@2: getRobustFormants=1; dawn@2: end dawn@2: end dawn@2: dawn@2: Dawn@4: % outputFileName = 'individualResults/kmeans_Results_'; Dawn@4: % resultsFileName = 'kmeans_Results_'; dawn@2: titleName = ''; dawn@2: for i=1 : noOfArguments dawn@2: % outputFileName = [ outputFileName varargin{i} '_']; dawn@2: % resultsFileName = [ resultsFileName varargin{i} '_']; dawn@2: titleName = [ titleName varargin{i} '_']; dawn@2: fprintf( masterFileOutputID, '%s_', varargin{i} ); dawn@2: end dawn@2: dawn@2: % titleName = outputFileName; Dawn@4: % outputFileName = [ outputFileName titleName ]; Dawn@4: % resultsFileName = [ resultsFileName titleName ]; dawn@2: dawn@2: fprintf( masterFileOutputID, '\t' ); dawn@2: Dawn@4: % outputFileName = [ outputFileName '.txt']; Dawn@4: % resultsFileName = [ resultsFileName '.txt']; dawn@2: Dawn@4: % fileOutputID = fopen( outputFileName, 'w' ); Dawn@4: % fileKMeansOutputID = fopen( resultsFileName, 'w' ); dawn@2: dawn@2: % -------------------- get the data from the results file --------------- dawn@2: lineCount = 0; dawn@2: fileCount = 0; dawn@2: data = []; dawn@2: while( ~(feof(inputFileID)) ) dawn@2: dawn@2: outputValues = []; dawn@2: % sampleEmotion = []; dawn@2: % gender = []; dawn@2: dawn@2: thestr = fgetl(inputFileID); dawn@2: if( lineCount > 10 ) % skip the file header dawn@2: fileCount = fileCount + 1; dawn@2: dawn@2: % determine whether we have a positive or negative sample dawn@2: sampleEmotion( fileCount ) = 'U'; dawn@2: if( ~(isempty(strfind(thestr,'pos')))) dawn@2: % sample is positive dawn@2: sampleEmotion( fileCount ) = 'P'; dawn@2: elseif( ~(isempty(strfind(thestr,'neg')))) dawn@2: % sample is negative dawn@2: sampleEmotion( fileCount ) = 'N'; dawn@2: else dawn@2: disp('EEEK!'); dawn@2: pause; dawn@2: end dawn@2: dawn@2: % determine whether we have a male, female or trans sample dawn@2: gender( fileCount ) = '?'; dawn@2: if( ~(isempty(strfind(thestr,'fem')))) dawn@2: % gender is female dawn@2: gender( fileCount ) = 'F'; dawn@2: elseif( ~(isempty(strfind(thestr,'male')))) dawn@2: % gender is male dawn@2: gender( fileCount ) = 'M'; dawn@2: elseif( ~(isempty(strfind(thestr,'trans')))) dawn@2: % gender is trans dawn@2: gender( fileCount ) = 'T'; dawn@2: else dawn@2: disp('EEEK!'); dawn@2: pause; dawn@2: end dawn@2: dawn@2: %how many values are in the string? dawn@2: spaces = strfind( thestr, ' ' ); dawn@2: numberstr = thestr( spaces(1) : end ); % chop off the file name dawn@2: frmtpos = strfind( numberstr, 'maxNoOfFormants'); % find the position of the label for number of formants dawn@2: dawn@2: str1 = numberstr( 1 : frmtpos(1)-1 ); % string contains jitter and shimmer values dawn@2: str2 = numberstr( frmtpos(1) : frmtpos(2)-1 ); % string contains all BURG formant information dawn@2: str3 = numberstr( frmtpos(2) : frmtpos(3)-1 ); % string contains all ALL formant information dawn@2: str4 = numberstr( frmtpos(3) : end ); % string contains all ROBUST formant information dawn@2: dawn@2: vars = sscanf( str1, '%f', inf ); dawn@2: % extract the shimmer and jitter values dawn@2: outputValues = [ outputValues vars( columnIndices )']; dawn@2: dawn@2: if( getBURGFormants ) dawn@2: spaces = strfind( str2, ' ' ); % remove the string 'maxNoOfFormants' dawn@2: vars = sscanf( str2( spaces(1) : end ), '%f', inf ); dawn@2: outputValues = stripOutFormantValues( vars, outputValues ); dawn@2: end dawn@2: Dawn@4: if( getAllFormants ) dawn@2: spaces = strfind( str3, ' ' ); % remove the string 'maxNoOfFormants' dawn@2: vars = sscanf( str3( spaces(1) : end ), '%f', inf ); dawn@2: outputValues = stripOutFormantValues( vars, outputValues ); dawn@2: end dawn@2: dawn@2: if( getRobustFormants ) dawn@2: spaces = strfind( str4, ' ' ); % remove the string 'maxNoOfFormants' dawn@2: vars = sscanf( str4( spaces(1) : end ), '%f', inf ); dawn@2: outputValues = stripOutFormantValues( vars, outputValues ); dawn@2: end dawn@2: dawn@2: [m n] = size( data ); dawn@2: % sometimes the 'all' formants command gives us fewer formants than dawn@2: % usual. If this is the case,then we will have to pad with zeros dawn@2: % for now. dawn@2: if( n > length( outputValues ) ) dawn@2: lenDiff = n - length( outputValues ); dawn@2: outputValues = [ outputValues zeros( 1, lenDiff ) ]; dawn@2: end dawn@2: dawn@2: data( fileCount, : ) = outputValues; dawn@2: dawn@2: end dawn@2: lineCount = lineCount + 1; dawn@2: dawn@2: end dawn@2: fclose(inputFileID); dawn@2: dawn@2: % ------------ apply the k-means classifier ------------------------ dawn@2: dawn@2: noOfClusters = 2; % we are only trying to identify positive and negative emotions dawn@2: dawn@2: dawn@2: [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... dawn@2: 'start', 'sample', 'Distance', 'cityblock'); dawn@2: dawn@2: %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 ); dawn@2: dawn@2: Dawn@4: fprintf( masterFileOutputID, 'sqEuclidean \n'); dawn@2: [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... dawn@2: 'start', 'sample', 'Distance', 'sqEuclidean'); dawn@2: Dawn@4: [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, sampleEmotion, masterFileOutputID, titleName, DEBUG ); Dawn@4: [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); dawn@2: Dawn@4: % ------------ dawn@2: Dawn@4: % % display results grouped by gender Dawn@4: % fprintf( masterFileOutputID, '\n Gender grouping \n'); Dawn@4: % noOfClusters = 3; Dawn@4: % Dawn@4: % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: % 'start', 'sample', 'Distance', 'cityblock'); Dawn@4: % Dawn@4: % fprintf( masterFileOutputID, 'cityblock \n'); Dawn@4: % [ groupStats, groupNames ] = processKMeansResults( 'cityblock', idx, gender, masterFileOutputID, titleName, DEBUG ); Dawn@4: % [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); Dawn@4: % Dawn@4: % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: % 'start', 'sample', 'Distance', 'sqEuclidean'); Dawn@4: % Dawn@4: % fprintf( masterFileOutputID, 'sqEuclidean \n'); Dawn@4: % [ groupStats, groupNames ] = processKMeansResults( 'sqEuclidean', idx, gender, masterFileOutputID, titleName, DEBUG ); Dawn@4: % [ confusionMatrix ] = getConfusionMatrix( groupStats, groupNames, masterFileOutputID ); Dawn@4: % Dawn@4: % dawn@2: Dawn@4: % Dawn@4: % % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: % % 'start', 'sample', 'Distance', 'cosine'); Dawn@4: % % Dawn@4: % % processKMeansResults( 'cosine', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName); Dawn@4: % % Dawn@4: % % disp('press space'); Dawn@4: % % pause; Dawn@4: % Dawn@4: % % [idx ctrs]=kmeans( data, noOfClusters, 'Replicates',100,... Dawn@4: % % 'start', 'sample', 'Distance', 'correlation'); Dawn@4: % % Dawn@4: % % processKMeansResults( 'correlation', idx, sampleEmotion, fileOutputID, fileKMeansOutputID, masterFileOutputID, titleName ); dawn@2: dawn@2: fprintf( masterFileOutputID, '\n' ); dawn@2: fclose( masterFileOutputID ); dawn@2: dawn@2: end dawn@2: dawn@2: %------------------------------------------------------------------ dawn@2: dawn@2: function [ outputValues ] = stripOutFormantValues( vars, outputValues ) dawn@2: dawn@2: noOfFormantValues = length( vars ) - 1; % gives the number of formant arguments only dawn@2: noOfFormants = vars(1); dawn@2: % there are 12 measurements for the mean of all formants (so the number dawn@2: % of formants is not important) for each formant measurement. dawn@2: if( noOfFormants ~= (noOfFormantValues-12)/24 ) dawn@2: disp('EEK!'); dawn@2: pause; dawn@2: else dawn@2: outputValues = [ outputValues vars( 2:end )' ]; dawn@2: end dawn@2: dawn@2: end dawn@2: dawn@2: %-------------------------------------------------------------------