bleeck@4: % generating function for 'aim-mat' bleeck@4: % bleeck@4: % INPUT VALUES: bleeck@4: % bleeck@4: % RETURN VALUE: bleeck@4: % bleeck@4: % bleeck@4: % (c) 2003, University of Cambridge, Medical Research Council bleeck@4: % Stefan Bleeck (stefan@bleeck.de) bleeck@4: % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual bleeck@4: % Christoph Lindner bleeck@4: % $Date: 2003/07/17 10:56:16 $ bleeck@4: % $Revision: 1.5 $ bleeck@4: bleeck@4: function displaypitchstrength(sai,options,frame_number,ax) bleeck@4: if nargin<4 bleeck@4: ax=gca; bleeck@4: end bleeck@4: bleeck@4: % ?????? per Definition ???? bleeck@4: minimum_time_interval=0.1; % in ms bleeck@4: maximum_time_interval=35; bleeck@4: bleeck@4: ti_result=options.handles.data.usermodule{frame_number}.ti_result; bleeck@4: f_result=options.handles.data.usermodule{frame_number}.f_result; bleeck@4: bleeck@4: fq_sum = f_result.smoothed_signal; bleeck@4: int_sum = ti_result.smoothed_signal; bleeck@4: cla; bleeck@4: hold on bleeck@4: bleeck@4: % TIP bleeck@4: tip=getvalues(int_sum); bleeck@4: % the tip is in the form of a logarithmic signal, it must therfore be bleeck@4: % transformed back to linear: bleeck@4: bleeck@4: tip_x = bin2time(int_sum, 1:length(tip)); % Get the times bleeck@4: tip_x = tip_x((tip_x>=(minimum_time_interval/1000)) & tip_x<=(maximum_time_interval/1000)); bleeck@4: tip = tip(time2bin(int_sum,tip_x(1)):time2bin(int_sum,tip_x(end))); bleeck@4: % tip_x is in ms. Change to Hz bleeck@4: tip_x = 1./tip_x; bleeck@4: % plot(tip_x, tip, 'b'); bleeck@4: bleeck@4: % plot the smoothed interval profile, from which the pitch was derived bleeck@4: smoothed_signal=ti_result.smoothed_signal; bleeck@4: % if ~isempty(smoothed_signal) bleeck@4: % smoothed_signal=linsigx(smoothed_signal); % change the logarithmic signal back to linear bleeck@4: % % smoothed_signal=reverse(smoothed_signal); bleeck@4: % smoothval=getvalues(smoothed_signal); bleeck@4: % s_x = bin2time(smoothed_signal, 1:length(smoothval)); % Get the times bleeck@4: % s_x = s_x((s_x>=(minimum_time_interval/1000)) & s_x<=(maximum_time_interval/1000)); bleeck@4: % bleeck@4: % smoothval=smoothval(time2bin(smoothed_signal,s_x(1)):time2bin(smoothed_signal,s_x(end))); bleeck@4: % % s_x=f2f(s_x,0,0.035,0.0001,0.035); bleeck@4: % % s_x=(s_x+0.0001); %?????????? bleeck@4: % % s_x=s_x*1.01; %?????????? bleeck@4: % s_x=1./s_x; bleeck@4: % plot(ax,s_x,smoothval,'b'); bleeck@4: % end bleeck@4: bleeck@4: % set(gca,'XScale','log'); bleeck@4: plot(smoothed_signal); bleeck@4: hold on bleeck@4: bleeck@4: % xlabel('Frequency [Hz]'); bleeck@4: set(gca, 'YAxisLocation','right'); bleeck@4: pks = []; bleeck@4: bleeck@4: nr_labels = 8; bleeck@4: ti=50*power(2,[0:nr_labels]); bleeck@4: for i=1:length(pks) bleeck@4: ti = ti((ti>(pks(i)+pks(i)*0.1))|(ti1 bleeck@4: % for ii=1:length(peaks) bleeck@4: for i=1:3 bleeck@4: t=peaks2{i}.t; bleeck@4: ypeak=peaks2{i}.y; bleeck@4: % ps=peaks{ii}.pitchstrength; bleeck@4: ps=peaks2{i}.v2012_height_base_width_ratio; bleeck@4: bleeck@4: bleeck@4: if i==1 bleeck@4: plot(t,ypeak,'Marker','o','Markerfacecolor','b','MarkeredgeColor','b','MarkerSize',10); bleeck@4: text(t,ypeak*1.05,sprintf('%3.0f Hz: %4.2f ',1/t,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','b','Fontsize',12); bleeck@4: else bleeck@4: plot(t,ypeak,'Marker','o','Markerfacecolor','g','MarkeredgeColor','w','MarkerSize',5); bleeck@4: text(t,ypeak*1.05,sprintf('%3.0f Hz: %4.2f ',1/t,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','g','Fontsize',12); bleeck@4: end bleeck@4: plot(peaks2{i}.left.t,peaks2{i}.left.y,'Marker','o','Markerfacecolor','r','MarkeredgeColor','r','MarkerSize',5); bleeck@4: plot(peaks2{i}.right.t,peaks2{i}.right.y,'Marker','o','Markerfacecolor','r','MarkeredgeColor','r','MarkerSize',5); bleeck@4: bleeck@4: bleeck@4: ybase=peaks2{i}.v2012_base_where_widths; bleeck@4: line([t t],[ybase ypeak],'color','m'); bleeck@4: line([peaks2{i}.left.t peaks2{i}.right.t],[ybase ybase],'color','m'); bleeck@4: end bleeck@4: end bleeck@4: bleeck@4: if target_frequency>0 % search only at one special frequency bleeck@4: found_fre=ti_result.fixed.highest_peak_frequency; bleeck@4: if found_fre>0 bleeck@4: yval=gettimevalue(smoothed_signal,1/found_fre); bleeck@4: else bleeck@4: yval=0; bleeck@4: end bleeck@4: plot(found_fre,yval,'Marker','o','Markerfacecolor','y','MarkeredgeColor','w','MarkerSize',5); bleeck@4: bleeck@4: found_ps=ti_result.fixed.highest_peak_hight; bleeck@4: plot(found_fre,yval,'Marker','o','Markerfacecolor','g','MarkeredgeColor','w','MarkerSize',10); bleeck@4: 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: bordery=get(gca,'Ylim'); bleeck@4: line([target_frequency target_frequency],[bordery(1) bordery(2)],'color','g') bleeck@4: min_fre=target_frequency/options.allowed_frequency_deviation; bleeck@4: max_fre=target_frequency*options.allowed_frequency_deviation; bleeck@4: line([min_fre min_fre],[bordery(1) bordery(2)],'color','g') bleeck@4: line([max_fre max_fre],[bordery(1) bordery(2)],'color','g') bleeck@4: end bleeck@4: bleeck@4: % maxy=sai{end}.ti_resultlt.peaks{1}.y; bleeck@4: maxy=max(int_sum); bleeck@4: if maxy==0 bleeck@4: maxy=1; bleeck@4: end bleeck@4: set(ax,'Ylim',[0,maxy*1.1]); bleeck@4: bleeck@4: bleeck@4: % plot the frequency profile bleeck@4: plot_frequency_profile=0; bleeck@4: if plot_frequency_profile bleeck@4: %Plot both profiles into one figure bleeck@4: % FQP bleeck@4: fqp = getvalues(fq_sum)'; bleeck@4: % fqp = fqp /1000; bleeck@4: plot(sai{frame_number}.channel_center_fq, fqp,'r'); bleeck@4: bleeck@4: peaks=f_result.peaks; bleeck@4: if length(peaks)>1 bleeck@4: % for ii=1:length(peaks) bleeck@4: for ii=1:1 bleeck@4: fre=1/peaks{ii}.t; bleeck@4: yval=peaks{ii}.y; bleeck@4: % ps=peaks{ii}.pitchstrength; bleeck@4: ps=peaks{ii}.y; bleeck@4: if ii==1 bleeck@4: plot(fre,yval,'Marker','o','Markerfacecolor','r','MarkeredgeColor','r','MarkerSize',10); bleeck@4: text(fre,yval*1.03,sprintf('%3.0f Hz: %4.2f ',fre,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','r','Fontsize',12); bleeck@4: else bleeck@4: plot(fre,yval,'Marker','o','Markerfacecolor','g','MarkeredgeColor','w','MarkerSize',5); bleeck@4: text(fre,yval*1.03,sprintf('%3.0f Hz: %4.2f ',fre,ps),'VerticalAlignment','bottom','HorizontalAlignment','center','color','g','Fontsize',12); bleeck@4: end bleeck@4: end bleeck@4: end bleeck@4: hold off bleeck@4: end bleeck@4: bleeck@4: bleeck@4: return bleeck@4: bleeck@4: function fre=x2fre(sig,x) bleeck@4: t_log = bin2time(sig,x); bleeck@4: t=f2f(t_log,0,0.035,0.001,0.035,'linlog'); bleeck@4: fre=1/t;