tomwalters@0: function ret_field=createscaleprofile(current_frame,options) tomwalters@0: % creates a profile with an angle to the auditory image. The angle is tomwalters@0: % ususally 45° and therefore the result is the collapsed Mellin image tomwalters@0: % tomwalters@0: tomwalters@0: % do we want debugging graphic? (very nice!!) tomwalters@0: grafix=0; tomwalters@0: tomwalters@0: % the angle of the profile tomwalters@0: if isfield(options,'angle') tomwalters@0: angle=options.angle; tomwalters@0: else tomwalters@0: angle=45; % in degrees tomwalters@0: end tomwalters@0: tomwalters@0: % the borders of the profiles are given by the minimum and the maximum tomwalters@0: % harmonic relationship: tomwalters@0: if isfield(options,'min_harmonic_relationship') tomwalters@0: min_harmonic_relationship=options.min_harmonic_relationship; tomwalters@0: else tomwalters@0: min_harmonic_relationship=0.5; tomwalters@0: end tomwalters@0: if isfield(options,'max_harmonic_relationship') tomwalters@0: max_harmonic_relationship=options.max_harmonic_relationship; tomwalters@0: else tomwalters@0: max_harmonic_relationship=20; tomwalters@0: end tomwalters@0: % how many points do we want to have on our profile? tomwalters@0: if isfield(options,'nr_points') tomwalters@0: nr_points=options.nr_points; tomwalters@0: else tomwalters@0: nr_points=200; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: % if we know about the periodicity, we can restrict ourself to the tomwalters@0: % interesting region tomwalters@0: if isfield(options,'periodicity') tomwalters@0: periodicity=options.periodicity; tomwalters@0: else tomwalters@0: periodicity=0.035; % in seconds tomwalters@0: end tomwalters@0: tomwalters@0: % translate to radian tomwalters@0: angle=angle*2*pi/360; tomwalters@0: tanangle=tan(angle); % accelerate tomwalters@0: tomwalters@0: cfs=getcf(current_frame); tomwalters@0: tomwalters@0: vals=getvalues(current_frame); tomwalters@0: nr_channels=getnrchannels(current_frame); tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: t_min=getminimumtime(current_frame); tomwalters@0: t_max=getmaximumtime(current_frame); tomwalters@0: tomwalters@0: if periodicity < t_max tomwalters@0: t_max=periodicity; tomwalters@0: end tomwalters@0: tomwalters@0: if t_min==0 tomwalters@0: t_min=0.0001; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: fre_min=1/t_max; tomwalters@0: if t_min>0 tomwalters@0: fre_max=1/t_min; tomwalters@0: else tomwalters@0: fre_max=1000; tomwalters@0: end tomwalters@0: tomwalters@0: % das ist die niedrigste Frequenz, die auf der Basilarmembran zu finden ist tomwalters@0: min_fre_current_frame=cfs(1); tomwalters@0: % das bedeutet, dass wir über die harmonischen Grenzen rausfinden können, tomwalters@0: % wie groß der Bereich ist, den wir gehen müssen: tomwalters@0: % die untere harmonische Zahl gibt uns den oberen Wert: tomwalters@0: smallest_interval_value=min_harmonic_relationship/min_fre_current_frame; tomwalters@0: biggest_interval_value=max_harmonic_relationship/min_fre_current_frame; tomwalters@0: tomwalters@0: % wieviel cent wollen wir tatsächlich untersuchen lassen: tomwalters@0: % nr_cent=fre2cent(1/biggest_interval_value,1/smallest_interval_value); % so viele cent sind insgesamt im interval profile tomwalters@0: % wir starten von links nach rechts und gehen in Schrittweite tomwalters@0: % start_cent=fre2cent(fre_min,1/biggest_interval_value); tomwalters@0: tomwalters@0: % Die Schrittweite berechnet sich aus den Extremen: tomwalters@0: % delta_cent=nr_cent/(nr_points-1); tomwalters@0: tomwalters@0: res_vals=zeros(1,nr_points); tomwalters@0: for jj=1:nr_channels tomwalters@0: current_channel(jj)=getsinglechannel(current_frame,jj); tomwalters@0: end tomwalters@0: if grafix tomwalters@0: colors=['b','r','g','c','m','k','y']; tomwalters@0: figure(2); tomwalters@0: clf tomwalters@0: hold on tomwalters@0: str.is_log=1; tomwalters@0: str.time_reversed=1; tomwalters@0: str.minimum_time=t_min; tomwalters@0: str.maximum_time=t_max; tomwalters@0: plot(current_frame/1,str); tomwalters@0: end tomwalters@0: tomwalters@0: % start_harmonic_relations=linspace(min_harmonic_relationship,max_harmonic_relationship,nr_points); tomwalters@0: start_harmonic_relations=distributelogarithmic(min_harmonic_relationship,max_harmonic_relationship,nr_points); tomwalters@0: tomwalters@0: tomwalters@0: channel_step=1; % skip maybe some channels tomwalters@0: nr_y_dots=floor(length(cfs)/channel_step); tomwalters@0: % the result is a twoDfield with x=harmonic number and y=whateverthisis tomwalters@0: % the number of field entries is given by the given number and the number tomwalters@0: % of channels tomwalters@0: result_field=zeros(nr_points,nr_y_dots); tomwalters@0: tomwalters@0: tomwalters@0: for ii=1:nr_points tomwalters@0: current_start_cent=fre2cent(fre_min,cfs(1)/start_harmonic_relations(ii)); tomwalters@0: y_count=1; tomwalters@0: for jj=1:channel_step:nr_channels tomwalters@0: % soviel cent ist dieser Kanal über dem ersten tomwalters@0: channel_diff_cent=fre2cent(cfs(1),cfs(jj)); tomwalters@0: % soviel cent gehen wir nach rechts im Intervall tomwalters@0: cur_cent_x=channel_diff_cent/tanangle+current_start_cent; tomwalters@0: % das bedeutet diese Frequenz auf der Intervallachse: tomwalters@0: cur_fre=cent2fre(fre_min,cur_cent_x); tomwalters@0: cur_time=1/cur_fre; tomwalters@0: if cur_time> t_min && cur_time < t_max tomwalters@0: cur_val=gettimevalue(current_channel(jj),cur_time); tomwalters@0: if grafix tomwalters@0: col=colors(mod(ii,7)+1); tomwalters@0: plot3(time2bin(current_frame,cur_time),jj,cur_val/30,'.','color',col); tomwalters@0: end tomwalters@0: else tomwalters@0: cur_val=0; tomwalters@0: end tomwalters@0: result_field(ii,y_count)=cur_val; tomwalters@0: y_count=y_count+1; tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: % ret_field=frame(result_field'); tomwalters@0: % ret_field=setstarttime(ret_field,min_harmonic_relationship); tomwalters@0: % newsr=nr_points/(max_harmonic_relationship-min_harmonic_relationship); tomwalters@0: % ret_field=setsr(ret_field,newsr); tomwalters@0: % ret_field=setxaxisname(ret_field,'harmonic ratio'); tomwalters@0: % return tomwalters@0: tomwalters@0: % next step: calculate the autocorrelation function in each channel: tomwalters@0: tomwalters@0: % grafix=1; tomwalters@0: % res_field2=result_field; tomwalters@0: % for ii=1:nr_points; tomwalters@0: % spalte=result_field(ii,:); tomwalters@0: % sig=signal(spalte,1); tomwalters@0: % acsig=autocorrelate(sig,1,getnrpoints(sig)); tomwalters@0: % acsigvals=getvalues(acsig); tomwalters@0: % res_field2(ii,:)=acsigvals'; tomwalters@0: % tomwalters@0: % % fftsig=powerspectrum(sig); tomwalters@0: % % nrs=linspace(1,getnrpoints(fftsig),getnrpoints(sig)); tomwalters@0: % % ftsigvals=getvalues(fftsig); tomwalters@0: % % ftsigvals=ftsigvals(round(nrs)); tomwalters@0: % % res_field2(ii,:)=-ftsigvals'; tomwalters@0: % tomwalters@0: % tomwalters@0: % % if grafix tomwalters@0: % % figure(23423) tomwalters@0: % % clf tomwalters@0: % % hold on tomwalters@0: % % plot(acsig/max(acsig),'r'); tomwalters@0: % % plot(ftsigvals/min(ftsigvals),'r'); tomwalters@0: % % plot(sig/max(sig)); tomwalters@0: % % end tomwalters@0: % p=0; tomwalters@0: % end tomwalters@0: tomwalters@0: % result_field=result_field'; tomwalters@0: % result_field=result_field(end:-1:1,:); tomwalters@0: % result_field=result_field(:,end:-1:1); tomwalters@0: ret_field=frame(result_field'); tomwalters@0: tomwalters@0: ret_field=setstarttime(ret_field,min_harmonic_relationship); tomwalters@0: newsr=nr_points/(max_harmonic_relationship-min_harmonic_relationship); tomwalters@0: ret_field=setsr(ret_field,newsr); tomwalters@0: ret_field=setxaxisname(ret_field,'harmonic ratio'); tomwalters@0: % ret_field=setyaxisname(ret_field,'erb distance'); tomwalters@0: tomwalters@0: % supr=suprisemap(result_field); tomwalters@0: % ret_field=supr'; tomwalters@0: return tomwalters@0: tomwalters@0: % one dimensional profile tomwalters@0: profile=signal(res_vals); tomwalters@0: % profile=setunit_x(profile,'scaling-frequency dimension'); tomwalters@0: tomwalters@0: tomwalters@0: % scaliere die x-achse auf das wachsende harmonische Verhältnis: tomwalters@0: % chr=current_harmonic_relation(end:-1:1); tomwalters@0: % rprof=res_vals(end:-1:1); tomwalters@0: % rprof=signal(rprof); tomwalters@0: % nr_dots=length(chr); tomwalters@0: % for i=1:length(chr) tomwalters@0: % n_y=f2f(i,1,nr_dots,min_harmonic_relationship,max_harmonic_relationship); tomwalters@0: % rx=interp1(chr,1:nr_dots,n_y); tomwalters@0: % nprof(i)=getbinvalue(rprof,rx); tomwalters@0: % end tomwalters@0: % tomwalters@0: % profile=signal(nprof); tomwalters@0: profile=setstarttime(profile,min_harmonic_relationship); tomwalters@0: newsr=getnrpoints(profile)/(max_harmonic_relationship-min_harmonic_relationship); tomwalters@0: profile=setsr(profile,newsr); tomwalters@0: profile=setunit_x(profile,'harmonic ratio');