d@0: function plotData(smFactor, normFact, quest, inton, individuals, meanPlot) d@0: d@0: d@0: %% d@0: % Written by Dave Moffat Jan 2015 d@0: % plotData reads in all csv files from attached dataset and analyses the d@0: % data to produce and save a range of plots based on imput values d@0: % smFactor: Smoothing factor used to smooth initial noisy data (50) d@0: % normFact: Boolean Flag as whether to normalise time and frequency d@0: % axes of data (1) d@0: % quest: Specific question types, eg: 'YN', Wh', 'all' d@0: % inton: Specific intonation tyoes, eg: 'RF', 'F', 'FR', 'R', 'H' d@0: % individuals: Boolean flag to plot all individual intonation patterns d@0: % meanPlot: Boolean flag to plot mean for intonation patterns d@0: d@0: d@0: d@0: trackData = readCSV('DataSetSummary.csv'); d@0: trackRange = size(trackData,1); d@0: plotCol = ['b','k','y','m','c','r','g']; d@0: plotCol = ['k','k']; d@0: colIndex = 1; d@0: figure; d@0: if(meanPlot) d@0: zerosPlot = [0:0.1:1]; d@0: totalF = zeros(1,length(zerosPlot)); d@0: end d@0: if(~individuals) d@0: hold on; d@0: end d@0: d@0: qList = findInCellArray(trackData,5,quest); d@0: if(isempty(qList)) d@0: qList = [1:trackRange]; d@0: end d@0: iList = findInCellArray(trackData,6,inton); d@0: if(isempty(iList)) d@0: iList = [1:trackRange]; d@0: end d@0: d@0: trackSearch = intersect(qList, iList); d@0: noTracks = length(trackSearch); d@0: d@0: for i = trackSearch d@0: i d@0: songTrack = csvread(strcat('T',num2str(i),'/01m.csv')); d@0: songTrack = songTrack(:,1:2); d@0: if(normFact) d@0: % Vertical d@0: songTrack(:,2) = songTrack(:,2) - min(songTrack(:,2)); d@0: songTrack(:,2) = songTrack(:,2) / max(songTrack(:,2)); d@0: % Horizontal d@0: songTrack(:,1) = songTrack(:,1) - min(songTrack(:,1)); d@0: songTrack(:,1) = songTrack(:,1) / max(songTrack(:,1)); d@0: end d@0: if(smFactor > 0) d@0: songTrack(:,2) = smooth(songTrack(:,2),smFactor); d@0: end d@0: plot(songTrack(:,1),songTrack(:,2),plotCol(mod(colIndex,length(plotCol))+1)); d@0: d@0: if(individuals) d@0: xlabel('Normalised Time'); d@0: ylabel('Normalised Frequency'); d@0: plotTitle =strcat('Question ',num2str(i),' Data Plot'); d@0: title(plotTitle); d@0: saveas(gcf,strcat('plots/plot',num2str(i)),'jpg'); d@0: else d@0: colIndex = colIndex +1; d@0: end d@0: if(meanPlot) d@0: if(isnan(songTrack(:,1))) d@0: noTracks = noTracks - 1; d@0: else d@0: songTrack(:,1); d@0: totalF = totalF + interp1(songTrack(:,1),songTrack(:,2),zerosPlot); d@0: end d@0: end d@0: end d@0: d@0: % if(~individuals) d@0: % xlabel('Normalised Time'); d@0: % ylabel('Normalised Frequency'); d@0: % plotTitle = strcat('plots/Questions:',quest,'-Intonation:',inton,' plot'); d@0: % title(plotTitle); d@0: % filename = strcat(quest,'Q-',inton,'I'); d@0: % saveas(gcf,filename,'jpg'); d@0: % end d@0: if(meanPlot) d@0: totalF = totalF / length(trackSearch); d@0: % figure; d@0: plot(zerosPlot,totalF,'LineWidth',2); d@0: xlabel('Normalised Time'); d@0: ylabel('Normalised Frequency'); d@0: plotTitle = strcat('plots/Questions:',quest,'-Intonation:',inton,' All Intonations and Mean plot'); d@0: % title(plotTitle); d@0: filename = strcat(quest,'Q-',inton,'-IMean-ALL'); d@0: saveas(gcf,filename,'pdf'); d@0: end d@0: d@0: d@0: end