bleeck@4
|
1 % generating function for 'aim-mat'
|
bleeck@4
|
2 %
|
bleeck@4
|
3 % INPUT VALUES:
|
bleeck@4
|
4 %
|
bleeck@4
|
5 % RETURN VALUE:
|
bleeck@4
|
6 %
|
bleeck@4
|
7 %
|
bleeck@4
|
8 % (c) 2003, University of Cambridge, Medical Research Council
|
bleeck@4
|
9 % Stefan Bleeck (stefan@bleeck.de)
|
bleeck@4
|
10 % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual
|
bleeck@4
|
11 % Christoph Lindner
|
bleeck@4
|
12 % $Date: 2003/07/17 10:56:16 $
|
bleeck@4
|
13 % $Revision: 1.5 $
|
bleeck@4
|
14
|
bleeck@4
|
15 function displaypitchstrength(sai,options,frame_number,ax)
|
bleeck@4
|
16 if nargin<4
|
bleeck@4
|
17 ax=gca;
|
bleeck@4
|
18 end
|
bleeck@4
|
19
|
bleeck@4
|
20 % ?????? per Definition ????
|
bleeck@4
|
21 minimum_time_interval=0.1; % in ms
|
bleeck@4
|
22 maximum_time_interval=35;
|
bleeck@4
|
23
|
bleeck@4
|
24 ti_result=options.handles.data.usermodule{frame_number}.ti_result;
|
bleeck@4
|
25 f_result=options.handles.data.usermodule{frame_number}.f_result;
|
bleeck@4
|
26
|
bleeck@4
|
27 fq_sum = f_result.smoothed_signal;
|
bleeck@4
|
28 int_sum = ti_result.smoothed_signal;
|
bleeck@4
|
29 cla;
|
bleeck@4
|
30 hold on
|
bleeck@4
|
31
|
bleeck@4
|
32 % TIP
|
bleeck@4
|
33 tip=getvalues(int_sum);
|
bleeck@4
|
34 % the tip is in the form of a logarithmic signal, it must therfore be
|
bleeck@4
|
35 % transformed back to linear:
|
bleeck@4
|
36
|
bleeck@4
|
37 tip_x = bin2time(int_sum, 1:length(tip)); % Get the times
|
bleeck@4
|
38 tip_x = tip_x((tip_x>=(minimum_time_interval/1000)) & tip_x<=(maximum_time_interval/1000));
|
bleeck@4
|
39 tip = tip(time2bin(int_sum,tip_x(1)):time2bin(int_sum,tip_x(end)));
|
bleeck@4
|
40 % tip_x is in ms. Change to Hz
|
bleeck@4
|
41 tip_x = 1./tip_x;
|
bleeck@4
|
42 % plot(tip_x, tip, 'b');
|
bleeck@4
|
43
|
bleeck@4
|
44 % plot the smoothed interval profile, from which the pitch was derived
|
bleeck@4
|
45 smoothed_signal=ti_result.smoothed_signal;
|
bleeck@4
|
46 % if ~isempty(smoothed_signal)
|
bleeck@4
|
47 % smoothed_signal=linsigx(smoothed_signal); % change the logarithmic signal back to linear
|
bleeck@4
|
48 % % smoothed_signal=reverse(smoothed_signal);
|
bleeck@4
|
49 % smoothval=getvalues(smoothed_signal);
|
bleeck@4
|
50 % s_x = bin2time(smoothed_signal, 1:length(smoothval)); % Get the times
|
bleeck@4
|
51 % s_x = s_x((s_x>=(minimum_time_interval/1000)) & s_x<=(maximum_time_interval/1000));
|
bleeck@4
|
52 %
|
bleeck@4
|
53 % smoothval=smoothval(time2bin(smoothed_signal,s_x(1)):time2bin(smoothed_signal,s_x(end)));
|
bleeck@4
|
54 % % s_x=f2f(s_x,0,0.035,0.0001,0.035);
|
bleeck@4
|
55 % % s_x=(s_x+0.0001); %??????????
|
bleeck@4
|
56 % % s_x=s_x*1.01; %??????????
|
bleeck@4
|
57 % s_x=1./s_x;
|
bleeck@4
|
58 % plot(ax,s_x,smoothval,'b');
|
bleeck@4
|
59 % end
|
bleeck@4
|
60
|
bleeck@4
|
61 % set(gca,'XScale','log');
|
bleeck@4
|
62 plot(smoothed_signal);
|
bleeck@4
|
63 hold on
|
bleeck@4
|
64
|
bleeck@4
|
65 % xlabel('Frequency [Hz]');
|
bleeck@4
|
66 set(gca, 'YAxisLocation','right');
|
bleeck@4
|
67 pks = [];
|
bleeck@4
|
68
|
bleeck@4
|
69 nr_labels = 8;
|
bleeck@4
|
70 ti=50*power(2,[0:nr_labels]);
|
bleeck@4
|
71 for i=1:length(pks)
|
bleeck@4
|
72 ti = ti((ti>(pks(i)+pks(i)*0.1))|(ti<pks(i)-pks(i)*0.1));
|
bleeck@4
|
73 end
|
bleeck@4
|
74 ti = [ti round(pks)];
|
bleeck@4
|
75 ti = sort(ti);
|
bleeck@4
|
76 % set(gca,'XTick', ti);
|
bleeck@4
|
77 % set(gca, 'XLim',[1000/maximum_time_interval sai{frame_number}.channel_center_fq(end)])
|
bleeck@4
|
78 set(options.handles.checkbox6, 'Value',0);
|
bleeck@4
|
79 set(options.handles.checkbox7, 'Value',0);
|
bleeck@4
|
80
|
bleeck@4
|
81
|
bleeck@4
|
82 % if there is a target frequency, then plot this one also!
|
bleeck@4
|
83 target_frequency=options.target_frequency;
|
bleeck@4
|
84 % at least three possibilities: take the hight:
|
bleeck@4
|
85 % pitchstrength=ti_result.free.highest_peak_hight;
|
bleeck@4
|
86 % dominant_frequency_found= ti_result.free.highest_peak_frequency;
|
bleeck@4
|
87
|
bleeck@4
|
88
|
bleeck@4
|
89 % three different pitch strengths
|
bleeck@4
|
90 % select the one with the highest peak rate
|
bleeck@4
|
91
|
bleeck@4
|
92 peaks=ti_result.peaks;
|
bleeck@4
|
93 % select the one with the highest neigbouring_ratio
|
bleeck@4
|
94 peaks2=sortstruct(peaks,'v2012_height_base_width_ratio');
|
bleeck@4
|
95 % peaks2=sortstruct(peaks,'peak_base_height_y');
|
bleeck@4
|
96 % peaks2=sortstruct(peaks,'y');
|
bleeck@4
|
97
|
bleeck@4
|
98
|
bleeck@4
|
99 if length(peaks2)>1
|
bleeck@4
|
100 % for ii=1:length(peaks)
|
bleeck@4
|
101 for i=1:3
|
bleeck@4
|
102 t=peaks2{i}.t;
|
bleeck@4
|
103 ypeak=peaks2{i}.y;
|
bleeck@4
|
104 % ps=peaks{ii}.pitchstrength;
|
bleeck@4
|
105 ps=peaks2{i}.v2012_height_base_width_ratio;
|
bleeck@4
|
106
|
bleeck@4
|
107
|
bleeck@4
|
108 if i==1
|
bleeck@4
|
109 plot(t,ypeak,'Marker','o','Markerfacecolor','b','MarkeredgeColor','b','MarkerSize',10);
|
bleeck@4
|
110 text(t,ypeak*1.05,sprintf('%3.0f Hz: %4.2f ',1/t,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','b','Fontsize',12);
|
bleeck@4
|
111 else
|
bleeck@4
|
112 plot(t,ypeak,'Marker','o','Markerfacecolor','g','MarkeredgeColor','w','MarkerSize',5);
|
bleeck@4
|
113 text(t,ypeak*1.05,sprintf('%3.0f Hz: %4.2f ',1/t,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','g','Fontsize',12);
|
bleeck@4
|
114 end
|
bleeck@4
|
115 plot(peaks2{i}.left.t,peaks2{i}.left.y,'Marker','o','Markerfacecolor','r','MarkeredgeColor','r','MarkerSize',5);
|
bleeck@4
|
116 plot(peaks2{i}.right.t,peaks2{i}.right.y,'Marker','o','Markerfacecolor','r','MarkeredgeColor','r','MarkerSize',5);
|
bleeck@4
|
117
|
bleeck@4
|
118
|
bleeck@4
|
119 ybase=peaks2{i}.v2012_base_where_widths;
|
bleeck@4
|
120 line([t t],[ybase ypeak],'color','m');
|
bleeck@4
|
121 line([peaks2{i}.left.t peaks2{i}.right.t],[ybase ybase],'color','m');
|
bleeck@4
|
122 end
|
bleeck@4
|
123 end
|
bleeck@4
|
124
|
bleeck@4
|
125 if target_frequency>0 % search only at one special frequency
|
bleeck@4
|
126 found_fre=ti_result.fixed.highest_peak_frequency;
|
bleeck@4
|
127 if found_fre>0
|
bleeck@4
|
128 yval=gettimevalue(smoothed_signal,1/found_fre);
|
bleeck@4
|
129 else
|
bleeck@4
|
130 yval=0;
|
bleeck@4
|
131 end
|
bleeck@4
|
132 plot(found_fre,yval,'Marker','o','Markerfacecolor','y','MarkeredgeColor','w','MarkerSize',5);
|
bleeck@4
|
133
|
bleeck@4
|
134 found_ps=ti_result.fixed.highest_peak_hight;
|
bleeck@4
|
135 plot(found_fre,yval,'Marker','o','Markerfacecolor','g','MarkeredgeColor','w','MarkerSize',10);
|
bleeck@4
|
136 text(found_fre/1.1,yval*1.01, ['Pitchstrength at fixed ' num2str(round(found_fre)) 'Hz: ' num2str(fround(found_ps,2)) ],'VerticalAlignment','bottom','HorizontalAlignment','right','color','g','Fontsize',12);
|
bleeck@4
|
137 bordery=get(gca,'Ylim');
|
bleeck@4
|
138 line([target_frequency target_frequency],[bordery(1) bordery(2)],'color','g')
|
bleeck@4
|
139 min_fre=target_frequency/options.allowed_frequency_deviation;
|
bleeck@4
|
140 max_fre=target_frequency*options.allowed_frequency_deviation;
|
bleeck@4
|
141 line([min_fre min_fre],[bordery(1) bordery(2)],'color','g')
|
bleeck@4
|
142 line([max_fre max_fre],[bordery(1) bordery(2)],'color','g')
|
bleeck@4
|
143 end
|
bleeck@4
|
144
|
bleeck@4
|
145 % maxy=sai{end}.ti_resultlt.peaks{1}.y;
|
bleeck@4
|
146 maxy=max(int_sum);
|
bleeck@4
|
147 if maxy==0
|
bleeck@4
|
148 maxy=1;
|
bleeck@4
|
149 end
|
bleeck@4
|
150 set(ax,'Ylim',[0,maxy*1.1]);
|
bleeck@4
|
151
|
bleeck@4
|
152
|
bleeck@4
|
153 % plot the frequency profile
|
bleeck@4
|
154 plot_frequency_profile=0;
|
bleeck@4
|
155 if plot_frequency_profile
|
bleeck@4
|
156 %Plot both profiles into one figure
|
bleeck@4
|
157 % FQP
|
bleeck@4
|
158 fqp = getvalues(fq_sum)';
|
bleeck@4
|
159 % fqp = fqp /1000;
|
bleeck@4
|
160 plot(sai{frame_number}.channel_center_fq, fqp,'r');
|
bleeck@4
|
161
|
bleeck@4
|
162 peaks=f_result.peaks;
|
bleeck@4
|
163 if length(peaks)>1
|
bleeck@4
|
164 % for ii=1:length(peaks)
|
bleeck@4
|
165 for ii=1:1
|
bleeck@4
|
166 fre=1/peaks{ii}.t;
|
bleeck@4
|
167 yval=peaks{ii}.y;
|
bleeck@4
|
168 % ps=peaks{ii}.pitchstrength;
|
bleeck@4
|
169 ps=peaks{ii}.y;
|
bleeck@4
|
170 if ii==1
|
bleeck@4
|
171 plot(fre,yval,'Marker','o','Markerfacecolor','r','MarkeredgeColor','r','MarkerSize',10);
|
bleeck@4
|
172 text(fre,yval*1.03,sprintf('%3.0f Hz: %4.2f ',fre,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','r','Fontsize',12);
|
bleeck@4
|
173 else
|
bleeck@4
|
174 plot(fre,yval,'Marker','o','Markerfacecolor','g','MarkeredgeColor','w','MarkerSize',5);
|
bleeck@4
|
175 text(fre,yval*1.03,sprintf('%3.0f Hz: %4.2f ',fre,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','g','Fontsize',12);
|
bleeck@4
|
176 end
|
bleeck@4
|
177 end
|
bleeck@4
|
178 end
|
bleeck@4
|
179 hold off
|
bleeck@4
|
180 end
|
bleeck@4
|
181
|
bleeck@4
|
182
|
bleeck@4
|
183 return
|
bleeck@4
|
184
|
bleeck@4
|
185 function fre=x2fre(sig,x)
|
bleeck@4
|
186 t_log = bin2time(sig,x);
|
bleeck@4
|
187 t=f2f(t_log,0,0.035,0.001,0.035,'linlog');
|
bleeck@4
|
188 fre=1/t;
|