function songDataSet = plotPitchData(globalPlot, songTypeIndex, intPattern)

pitchDataInput = 1:22;

% globalPlot = 0;
% pitchDataInput(11) = [];
% pitchDataInput(7) = [];
% pitchDataInput(6) = [];
% pitchDataInput(5) = [];
% pitchDataInput(3) = [];
% pitchDataInput(1) = [];

%  data = readInCSV('Dataset.csv')
% 
% songDataSet = {'How long has this been going on?',           'Wh';
%         'But don`t you remember?',                   'YN';
%         'Is there life on Mars?',                    'YN';
%         'Can you feel the love tonight?'             'YN';
%         'What have I done?',                         'Wh';
%         'Are we human or are we dancers?',           'Echo';
%         'How can anybody possibly know how I feel?', 'Wh';
%         'D`you know what I mean?',              	 'YN';
%         'Do you remember?',                          'YN';
%         'Do you remember the first time?',           'YN';
%         'Who want to live forever?',               	 'Wh';
%         'Is this the real life?',                	 'YN';
%         'Is this just fantasy?',                      'YN'};

% songDataSet = readDataSet;
songTypeArray = {'Wh', 'YN', 'All'};
intPatternArray = {'rf', 'f', 'rise-hold','all'};
% songType = songTypeArray{songTypeIndex}
validQuestion = [1:52];

% for i = pitchDataInput;
%     if(strcmp(songDataSet{i,2},songTypeArray{songTypeIndex}) || songTypeIndex == 3)
%         if(strcmp(songDataSet{i,3},intPatternArray{intPattern}))
%             validQuestion = cat(2,validQuestion,i);
%         elseif(intPattern == 4 && (~strcmp(songDataSet{i,3},'x')))
%             validQuestion = cat(2,validQuestion,i);
%         elseif(intPattern == 3 && ~(strcmp(songDataSet{i,3},'x') ||...
%                 strcmp(songDataSet{i,3},intPatternArray{1}) ||...
%                 strcmp(songDataSet{i,3},intPatternArray{2})))
%             validQuestion = cat(2,validQuestion,i); 
%         end
%     end
% end


% (songDataSet{:,2} == songType)

if(globalPlot)
    figure; hold on;
end

zerosPlot = 0:0.01:1;


totalF = zeros(1,length(zerosPlot));
    
% plotCol = ['y','m','c','r','g','b','k','y','m','c','r','g','b','k','y','m','c','r','g','b','k','y','m','c','r','g','b','k'];
plotCol = ['y','m','c','r','g','b','k'];
colIndex = 1;
for i = validQuestion
   i
    songTrack = csvread(strcat('T',num2str(i),'/01.csv'));    
    songTrack = songTrack(:,1:2);
%     songTrack = songTrack(ceil(end/2):end,:)
    songTrack(:,1) = songTrack(:,1) - min(songTrack(:,1));
    songTrack(:,1) = songTrack(:,1) / max(songTrack(:,1));
    if(0)
        songTrack(:,2) = songTrack(:,2) - min(songTrack(:,2));
        songTrack(:,2) = songTrack(:,2) / max(songTrack(:,2));
    end
    songTrack(:,2) = smooth(songTrack(:,2),50);
%     songTrack = songTrack(songTrack(:,1)<0.95,:);
%     songTrack(:,2) = songTrack(:,2) / min(songTrack(:,2));
%     songTrack(:,2) = songTrack(:,2) / max(songTrack(:,2));

    %totalF = totalF + interp1(songTrack(:,1),songTrack(:,2),zerosPlot); 

    songTrack(songTrack(:,2) == 0,:) = [];
    if(~globalPlot)
        plot(songTrack(:,1),songTrack(:,2),plotCol(mod(colIndex,7)+1));
        axis([0,1,50,500]);
        xlabel('Normalised Time');
        ylabel('Frequency (Hz)');
        plotTitle = strcat('Song: ',songDataSet{i,1} ,' Question Type: ',songDataSet{i,2}, ' with ', intPatternArray{intPattern}, ' Terminal Intonation');
        title(plotTitle);
        saveAsName = strcat('plots/plot',num2str(i));
        saveas(gcf,saveAsName,'pdf');
    else
    	plot(songTrack(:,1),songTrack(:,2),plotCol(mod(colIndex,7)+1));
    end
    

%     plot(songTrack(:,1),smooth(songTrack(:,2),size(songTrack,1)/20),plotCol(colIndex));
    colIndex = colIndex +1;
end

totalF = totalF / length(validQuestion);

if(globalPlot)
    xlabel('Normalised Time');
    ylabel('Normalised Frequency');
    plotTitle =strcat(songTypeArray{songTypeIndex},' Questions Data Plot with: ', intPatternArray{intPattern}, ' Terminal Intonation');
    title(plotTitle);
%     legend(songDataSet{pitchDataInput,1});
    saveAsTitle = strcat('plots/',songTypeArray{songTypeIndex},'QuestionsPlot', intPatternArray{intPattern}, 'Intonation');
    saveas(gcf,saveAsTitle,'pdf');
    hold off;
end

if(1)
    plot(zerosPlot, totalF);
%     axis([0,1,50,500]);
    xlabel('Normalised Time');
    ylabel('Frequency (Hz)');
    plotTitle = strcat(songTypeArray{songTypeIndex},' Questions Data Plot with: ', intPatternArray{intPattern}, ' Terminal Intonation Mean Results');
    title(plotTitle);
%     legend(songDataSet{pitchDataInput,1});
    saveAsTitle = strcat('plots/',songTypeArray{songTypeIndex},'QuestionsPlot', intPatternArray{intPattern}, 'IntonationMean');
    saveas(gcf,saveAsTitle,'pdf');
    hold off;
end



end