bleeck@4: % function [result, center_c] = analyse_frequency_profiletunedDP(fq_profile, peaks, apFQP) bleeck@4: % bleeck@4: % To analyse the time frequency profile of the auditory image bleeck@4: % Returns value between 0 and 1 discribing the strength of the spectral bleeck@4: % pitch. Used for quantitative analysis of ramped and damped sinusoids bleeck@4: % and for sinusoidally amplitude modulated sinusoids bleeck@4: % bleeck@4: % bleeck@4: % INPUT VALUES: bleeck@4: % fq_profile frequency profile (signal class) bleeck@4: % peaks output of peakpicker bleeck@4: % apFQP a priori information where to find the peak bleeck@4: % bleeck@4: % RETURN VALUE: bleeck@4: % result all relevant information bleeck@4: % bleeck@4: % bleeck@4: % (c) 2011, University of Southampton bleeck@4: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@4: % download of current version is on the soundsoftware site: bleeck@4: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@4: % documentation and everything is on http://www.acousticscale.org bleeck@4: bleeck@4: function result = analyse_frequency_profile(fq_profile, options) bleeck@4: bleeck@4: % for debug reasons - bleeck@4: plot_switch = 0; bleeck@4: bleeck@4: bleeck@4: % these finally are the results, that we want back: bleeck@4: % 1:the hight at the highest point bleeck@4: result.free.highest_peak_hight=0; bleeck@4: result.free.highest_peak_frequency=0; bleeck@4: % hight to the region below value bleeck@4: result.free.height_width_ratio=0; bleeck@4: bleeck@4: % now all these at a fixed frequency: bleeck@4: result.fixed.highest_peak_hight=0; bleeck@4: result.fixed.highest_peak_frequency=0; bleeck@4: result.fixed.height_width_ratio=0; bleeck@4: bleeck@4: % other things useful for plotting bleeck@4: result.smoothed_signal=fq_profile; % no smoothing used here bleeck@4: result.peaks = []; bleeck@4: bleeck@4: bleeck@4: % first find the peaks of the frequency profile bleeck@4: peaks = PeakPicker(fq_profile); bleeck@4: bleeck@4: % translate the time in the peaks back to a frequency bleeck@4: nap=options.nap; % ugly, but we need the frequency informatin somewhere bleeck@4: for i=1:length(peaks) bleeck@4: peaks{i}.t=1/chan2fre(nap,peaks{i}.x); bleeck@4: end bleeck@4: bleeck@4: result.peaks = peaks; bleeck@4: bleeck@4: fq_profile_vals = getdata(fq_profile); bleeck@4: if plot_switch bleeck@4: cf_save = gcf; bleeck@4: figure(13) bleeck@4: cla; bleeck@4: plot(fq_profile_vals,'r-'); bleeck@4: hold on bleeck@4: axis auto bleeck@4: end bleeck@4: % stop if there are no peaks, e.g. in the first frames bleeck@4: if length(peaks)<1 bleeck@4: return bleeck@4: end bleeck@4: bleeck@4: % Peak of interest is highest peak of the profile bleeck@4: peaks_oi = peaks{1}; bleeck@4: bleeck@4: apFQP=options.target_frequency; bleeck@4: if apFQP>0 bleeck@4: % no peak finding - peak is given a priori bleeck@4: % take nearest peak to a apriori frequency bleeck@4: dist=+inf; bleeck@4: indexOI = 1; bleeck@4: for p=1:length(peaks) bleeck@4: d=abs(apFQP-peaks{p}.t); bleeck@4: if dmaxy*atten_fac) bleeck@4: % pwidth=pwidth+1; % one more channel bleeck@4: % x=x+1; bleeck@4: % end bleeck@4: % if plot_switch bleeck@4: % line([x x],[0 peaks_oi.y]); bleeck@4: % end bleeck@4: % bleeck@4: % x = poi.x-1; bleeck@4: % while (x>=1)&&(fq_profile_vals(x)>maxy*atten_fac) bleeck@4: % pwidth=pwidth+1; % one more channel bleeck@4: % x=x-1; bleeck@4: % end bleeck@4: % if plot_switch bleeck@4: % line([x x],[0 peaks_oi.y]); bleeck@4: % end bleeck@4: % result_width = 1-(pwidth/length(fq_profile_vals)); bleeck@4: % bleeck@4: bleeck@4: % ---------------------------- bleeck@4: % Method developed with Roy 13/06 bleeck@4: % Calculate the mean of the Channels in a 20 to 80 percent bleeck@4: % range left of the main peak bleeck@4: bleeck@4: start_frequency_integration=options.start_frequency_integration; bleeck@4: stop_frequency_integration=options.stop_frequency_integration; bleeck@4: bleeck@4: startx=floor(start_frequency_integration*peaks_oi.x); bleeck@4: if startx<=0 bleeck@4: startx=1; bleeck@4: end bleeck@4: stopx=floor(stop_frequency_integration*peaks_oi.x); bleeck@4: ps_result = 1 - mean(fq_profile_vals(startx:stopx))/fq_profile_vals(peaks_oi.x); bleeck@4: bleeck@4: center_c = peaks_oi.x; bleeck@4: bleeck@4: if plot_switch bleeck@4: plot(peaks_oi.x,peaks_oi.y,'r.'); bleeck@4: plot(startx,fq_profile_vals(startx),'bx'); bleeck@4: line([startx startx],[0 fq_profile_vals(startx)]) bleeck@4: plot(stopx,fq_profile_vals(stopx),'bx'); bleeck@4: line([stopx stopx],[0 fq_profile_vals(stopx)]) bleeck@4: figure(cf_save); bleeck@4: end bleeck@4: bleeck@4: % % % For debug plot minima bleeck@4: % for i=1:nops bleeck@4: % plot(peaks{i}.left.x, peaks{i}.left.y, 'ob'); bleeck@4: % plot(peaks{i}.right.x, peaks{i}.right.y, 'xb'); bleeck@4: % end bleeck@4: bleeck@4: bleeck@4: % finally define the return values bleeck@4: result.free.highest_peak_hight=peaks_oi.y; % height of the first peak bleeck@4: result.free.highest_peak_frequency=chan2fre(nap,peaks_oi.x); bleeck@4: bleeck@4: % hight to the region below value bleeck@4: result.free.height_width_ratio=ps_result; bleeck@4: bleeck@4: % now all these at a fixed frequency: bleeck@4: result.fixed.highest_peak_hight=0; bleeck@4: result.fixed.highest_peak_frequency=0; bleeck@4: result.fixed.height_width_ratio=0; bleeck@4: bleeck@4: