d@0
|
1 function plotData(smFactor, normFact, quest, inton, individuals, meanPlot)
|
d@0
|
2
|
d@0
|
3
|
d@0
|
4 %%
|
d@0
|
5 % Written by Dave Moffat Jan 2015
|
d@0
|
6 % plotData reads in all csv files from attached dataset and analyses the
|
d@0
|
7 % data to produce and save a range of plots based on imput values
|
d@0
|
8 % smFactor: Smoothing factor used to smooth initial noisy data (50)
|
d@0
|
9 % normFact: Boolean Flag as whether to normalise time and frequency
|
d@0
|
10 % axes of data (1)
|
d@0
|
11 % quest: Specific question types, eg: 'YN', Wh', 'all'
|
d@0
|
12 % inton: Specific intonation tyoes, eg: 'RF', 'F', 'FR', 'R', 'H'
|
d@0
|
13 % individuals: Boolean flag to plot all individual intonation patterns
|
d@0
|
14 % meanPlot: Boolean flag to plot mean for intonation patterns
|
d@0
|
15
|
d@0
|
16
|
d@0
|
17
|
d@0
|
18 trackData = readCSV('DataSetSummary.csv');
|
d@0
|
19 trackRange = size(trackData,1);
|
d@0
|
20 plotCol = ['b','k','y','m','c','r','g'];
|
d@0
|
21 plotCol = ['k','k'];
|
d@0
|
22 colIndex = 1;
|
d@0
|
23 figure;
|
d@0
|
24 if(meanPlot)
|
d@0
|
25 zerosPlot = [0:0.1:1];
|
d@0
|
26 totalF = zeros(1,length(zerosPlot));
|
d@0
|
27 end
|
d@0
|
28 if(~individuals)
|
d@0
|
29 hold on;
|
d@0
|
30 end
|
d@0
|
31
|
d@0
|
32 qList = findInCellArray(trackData,5,quest);
|
d@0
|
33 if(isempty(qList))
|
d@0
|
34 qList = [1:trackRange];
|
d@0
|
35 end
|
d@0
|
36 iList = findInCellArray(trackData,6,inton);
|
d@0
|
37 if(isempty(iList))
|
d@0
|
38 iList = [1:trackRange];
|
d@0
|
39 end
|
d@0
|
40
|
d@0
|
41 trackSearch = intersect(qList, iList);
|
d@0
|
42 noTracks = length(trackSearch);
|
d@0
|
43
|
d@0
|
44 for i = trackSearch
|
d@0
|
45 i
|
d@0
|
46 songTrack = csvread(strcat('T',num2str(i),'/01m.csv'));
|
d@0
|
47 songTrack = songTrack(:,1:2);
|
d@0
|
48 if(normFact)
|
d@0
|
49 % Vertical
|
d@0
|
50 songTrack(:,2) = songTrack(:,2) - min(songTrack(:,2));
|
d@0
|
51 songTrack(:,2) = songTrack(:,2) / max(songTrack(:,2));
|
d@0
|
52 % Horizontal
|
d@0
|
53 songTrack(:,1) = songTrack(:,1) - min(songTrack(:,1));
|
d@0
|
54 songTrack(:,1) = songTrack(:,1) / max(songTrack(:,1));
|
d@0
|
55 end
|
d@0
|
56 if(smFactor > 0)
|
d@0
|
57 songTrack(:,2) = smooth(songTrack(:,2),smFactor);
|
d@0
|
58 end
|
d@0
|
59 plot(songTrack(:,1),songTrack(:,2),plotCol(mod(colIndex,length(plotCol))+1));
|
d@0
|
60
|
d@0
|
61 if(individuals)
|
d@0
|
62 xlabel('Normalised Time');
|
d@0
|
63 ylabel('Normalised Frequency');
|
d@0
|
64 plotTitle =strcat('Question ',num2str(i),' Data Plot');
|
d@0
|
65 title(plotTitle);
|
d@0
|
66 saveas(gcf,strcat('plots/plot',num2str(i)),'jpg');
|
d@0
|
67 else
|
d@0
|
68 colIndex = colIndex +1;
|
d@0
|
69 end
|
d@0
|
70 if(meanPlot)
|
d@0
|
71 if(isnan(songTrack(:,1)))
|
d@0
|
72 noTracks = noTracks - 1;
|
d@0
|
73 else
|
d@0
|
74 songTrack(:,1);
|
d@0
|
75 totalF = totalF + interp1(songTrack(:,1),songTrack(:,2),zerosPlot);
|
d@0
|
76 end
|
d@0
|
77 end
|
d@0
|
78 end
|
d@0
|
79
|
d@0
|
80 % if(~individuals)
|
d@0
|
81 % xlabel('Normalised Time');
|
d@0
|
82 % ylabel('Normalised Frequency');
|
d@0
|
83 % plotTitle = strcat('plots/Questions:',quest,'-Intonation:',inton,' plot');
|
d@0
|
84 % title(plotTitle);
|
d@0
|
85 % filename = strcat(quest,'Q-',inton,'I');
|
d@0
|
86 % saveas(gcf,filename,'jpg');
|
d@0
|
87 % end
|
d@0
|
88 if(meanPlot)
|
d@0
|
89 totalF = totalF / length(trackSearch);
|
d@0
|
90 % figure;
|
d@0
|
91 plot(zerosPlot,totalF,'LineWidth',2);
|
d@0
|
92 xlabel('Normalised Time');
|
d@0
|
93 ylabel('Normalised Frequency');
|
d@0
|
94 plotTitle = strcat('plots/Questions:',quest,'-Intonation:',inton,' All Intonations and Mean plot');
|
d@0
|
95 % title(plotTitle);
|
d@0
|
96 filename = strcat(quest,'Q-',inton,'-IMean-ALL');
|
d@0
|
97 saveas(gcf,filename,'pdf');
|
d@0
|
98 end
|
d@0
|
99
|
d@0
|
100
|
d@0
|
101 end |