function [] = get_PRAAT( dirName, statsFileID )

% this function collates the results of all values calculated using the PRAAT software 

    % identify the speaker in the stats file
    fprintf( statsFileID, '%s ', dirName );
    
% -------------- get the jitter metrics -------------------
%     JITTER: ddp \t local \t ppq5 \t rap \t 
    FileName = [ dirName '_jitter_ddp.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
      disp('WARNING: MISSING JITTER DDP METRICS FILE');
      fprintf( statsFileID, '\t ddp missing');
    else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    FileName = [ dirName '_jitter_local.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
      disp('WARNING: MISSING JITTER LOCAL METRICS FILE');
      fprintf( statsFileID, '\t local missing');
    else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    FileName = [ dirName '_jitter_ppq5.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
      disp('WARNING: MISSING JITTER PPQ5 METRICS FILE');
      fprintf( statsFileID, '\t ppq5 missing');
    else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    FileName = [ dirName '_jitter_rap.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
      disp('WARNING: MISSING JITTER RAP METRICS FILE');
      fprintf( statsFileID, '\t rap missing');
    else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    

%-------------- get the shimmer metrics ----------------------
%     SHIMMER: local \t dda \t apq3 \t apq5 \t apq11
    FileName = [ dirName '_shimmer_local.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
        disp('WARNING: MISSING SHIMMER METRICS FILE');   
        fprintf( statsFileID, '\t local missing');
     else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    FileName = [ dirName '_shimmer_dda.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
        disp('WARNING: MISSING SHIMMER METRICS FILE');   
        fprintf( statsFileID, '\t dda missing');
     else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    FileName = [ dirName '_shimmer_apq3.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
        disp('WARNING: MISSING SHIMMER METRICS FILE');   
        fprintf( statsFileID, '\t apq3 missing');
     else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    FileName = [ dirName '_shimmer_apq5.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
        disp('WARNING: MISSING SHIMMER METRICS FILE');   
        fprintf( statsFileID, '\t apq5 missing');
     else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
    FileName = [ dirName '_shimmer_apq11.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
        disp('WARNING: MISSING SHIMMER METRICS FILE');   
        fprintf( statsFileID, '\t apq11 missing');
     else
        shimmer = fscanf( FileID, '%f', inf );  
        fprintf( statsFileID, '\t %f ', shimmer );
    end
    fclose(FileID);
    
%-------------- get the formant metrics ----------------------        
    
    % need to discard all formant information for unvoiced frames.
    
    FileName = [ dirName '_Formant.txt'];
    FileID = fopen( FileName );
    if( FileID <= 0 ) %does the file exist?
        % if not
        disp('WARNING: MISSING FORMANT METRICS FILE');   
        fprintf( statsFileID, '\t formant missing');
     else
        % file format is not straight forward
        noOfValues = 0;
        formants = [];
        while( ~(feof(FileID)) )
            
            % search for numberOfFormants
            thestr = fgetl(FileID);%, '%s', 1);

            if( strfind( thestr , 'numberOfFormants' ) > 0 )
                noOfValues = noOfValues + 1;
                %numberOfFormants found
                pos = find( thestr == '=' );
                numberOfFormants = str2num(thestr(pos+2:end));
                formants( noOfValues, 1 ) = numberOfFormants;
                % discard the 'formant []' line
                thestr = fgetl(FileID);
                % now read the formant positions
                for (i=0:numberOfFormants-1)
                    thestr = fgetl(FileID);
                    pos = find( thestr == '=' );
                    formants( noOfValues, i+2 ) =  str2num(thestr( pos+2 : end ));
                end
                
                % discard the 'bandwidth []' line
                thestr = fgetl(FileID);
                % now read the formant bandwidths
                for (i=0:numberOfFormants-1)
                    thestr = fgetl(FileID);
                    pos = find( thestr == '=' );
                    formants( noOfValues, i+2+numberOfFormants ) =  str2num(thestr( pos+2 : end ));
                end
                
            end
        end
        fclose(FileID);    
    end

    
    