function [] = get_HNR( dirName, statsFileID )

DEBUG=1;
% this function collates the results of all HNR values

% identify the speaker in the stats file
fprintf( statsFileID, '%s ', dirName );

metricName = '_HNR';
metricFileName = [ dirName metricName '.txt'];
metrics = readValuesFromFile( statsFileID, metricFileName, metricName );

if(DEBUG)
    subplot(211);
    if( strfind( dirName, 'neg') )
        plot(metrics, 'b'); hold on;
    elseif( strfind( dirName, 'pos') )
        plot(metrics, 'r'); hold on;
    end
end

% get basic metric set
[ basicSet ] = basicMetricSet( metrics, statsFileID );


if(DEBUG)
    subplot(212); 
    if( strfind( dirName, 'neg') )
        plot(basicSet, 'xb'); hold on;
    elseif( strfind( dirName, 'pos') )
        plot(basicSet, 'xr'); hold on;
    end
end

% calculate the ratio of voiced (HNR > 0) to unvoiced frames (HNR <= 0)
noOfUnvoicedFrames = length( find( metrics <= 0 ));
noOfVoicedFrames = length( find( metrics > 0 ));
unvoicedToVoicedRatio = ( noOfUnvoicedFrames / noOfVoicedFrames );
fprintf( statsFileID, '\t %f ', unvoicedToVoicedRatio);

% calculate the average duration of the voiced and unvoiced periods

tsig = ( metrics > 0);
dsig = diff([1 tsig' 1]);
startIndex = find(dsig < 0);
endIndex = find(dsig > 0)-1;
unvoicedDuration = endIndex-startIndex+1;
meanUnvoicedDuration = mean( unvoicedDuration )
fprintf( statsFileID, '\t %f ', meanUnvoicedDuration);


startIndex = find(dsig > 0);
startIndex = startIndex(1:end-1);
endIndex = find(dsig < 0)-1;
endIndex = endIndex(2:end);
voicedDuration = endIndex-startIndex+1;
meanVoicedDuration = mean( voicedDuration )
fprintf( statsFileID, '\t %f ', meanVoicedDuration);


fprintf( statsFileID, '\n');