annotate aim-mat/tools/AIFrePtiP.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % tool
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
bleeck@3 8 % (c) 2011, University of Southampton
bleeck@3 9 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 10 % download of current version is on the soundsoftware site:
bleeck@3 11 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 12 % documentation and everything is on http://www.acousticscale.org
bleeck@3 13
tomwalters@0 14
tomwalters@0 15 function options=AIFrePtiP(framestruct_a);
tomwalters@0 16 % plots the current frame (cframe) together with its sum of intervals
tomwalters@0 17 % and the sum of frequencies
tomwalters@0 18 % no pitch is calculated or plotted! for this use AIFrePtiPstress
tomwalters@0 19 % all relevant data must be in the frame-object
tomwalters@0 20 % the return value "pitch" is the result from the call to "calcresidualprobability"
tomwalters@0 21
tomwalters@0 22
tomwalters@0 23 if ~isstruct(framestruct_a)
tomwalters@0 24 % error('AIsum must be called with a structure');
tomwalters@0 25 framestruct.current_frame=framestruct_a;
tomwalters@0 26 else
tomwalters@0 27 framestruct=framestruct_a;
tomwalters@0 28 end
tomwalters@0 29
tomwalters@0 30 if ~isfield(framestruct,'show_time');
tomwalters@0 31 show_time=1;
tomwalters@0 32 else
tomwalters@0 33 show_time=framestruct.show_time;
tomwalters@0 34 end
tomwalters@0 35
tomwalters@0 36 if ~isfield(framestruct,'plot_scale');
tomwalters@0 37 plot_scale=1;
tomwalters@0 38 else
tomwalters@0 39 plot_scale=framestruct.plot_scale;
tomwalters@0 40 end
tomwalters@0 41
tomwalters@0 42
tomwalters@0 43 if ~isfield(framestruct,'minimum_time_interval');
tomwalters@0 44 minimum_time_interval=1;
tomwalters@0 45 else
tomwalters@0 46 minimum_time_interval=framestruct.minimum_time_interval;
tomwalters@0 47 end
tomwalters@0 48
tomwalters@0 49 if ~isfield(framestruct,'is_log');
tomwalters@0 50 is_log=1;
tomwalters@0 51 else
tomwalters@0 52 is_log=framestruct.is_log;;
tomwalters@0 53 end
tomwalters@0 54
tomwalters@0 55 if isfield(framestruct,'frequency_profile_scale');
tomwalters@0 56 frequency_profile_scale=framestruct.frequency_profile_scale;
tomwalters@0 57 else
tomwalters@0 58 frequency_profile_scale=1;
tomwalters@0 59 end
tomwalters@0 60 if isfield(framestruct,'time_profile_scale');
tomwalters@0 61 time_profile_scale=framestruct.time_profile_scale;
tomwalters@0 62 else
tomwalters@0 63 time_profile_scale=1;
tomwalters@0 64 end
tomwalters@0 65 % if the time scale is reversed (time from left to right)
tomwalters@0 66 if isfield(framestruct,'time_reversed');
tomwalters@0 67 time_reversed=framestruct.time_reversed;
tomwalters@0 68 else
tomwalters@0 69 time_reversed=0;
tomwalters@0 70 end
tomwalters@0 71
tomwalters@0 72 % hier wird der current frame definiert:
tomwalters@0 73 current_frame=framestruct.current_frame;
tomwalters@0 74
tomwalters@0 75 if ~isfield(framestruct,'maximum_time_interval');
tomwalters@0 76 maximum_time_interval=35;
tomwalters@0 77 else
tomwalters@0 78 maximum_time_interval=framestruct.maximum_time_interval;
tomwalters@0 79 end
tomwalters@0 80
tomwalters@0 81 if maximum_time_interval/1000>getlength(current_frame)
tomwalters@0 82 maximum_time_interval=getlength(current_frame)*1000;
tomwalters@0 83 end
tomwalters@0 84
tomwalters@0 85 if isfield(framestruct,'options');
tomwalters@0 86 options=framestruct.options;
tomwalters@0 87 else
tomwalters@0 88 options=[];
tomwalters@0 89 end
tomwalters@0 90 if ~isfield(options,'oldhandle1')
tomwalters@0 91 options.oldhandle1=0;
tomwalters@0 92 end
tomwalters@0 93 if ~isfield(options,'oldhandle2')
tomwalters@0 94 options.oldhandle2=0;
tomwalters@0 95 end
tomwalters@0 96 if ~isfield(options,'oldhandle3')
tomwalters@0 97 options.oldhandle3=0;
tomwalters@0 98 end
tomwalters@0 99
tomwalters@0 100
tomwalters@0 101 % schmeisse die physikalisch nicht sinnvollen Bereiche raus!
tomwalters@0 102 % current_frame=extractpitchregion(current_frame);
tomwalters@0 103
tomwalters@0 104 scale_summe=getscalesumme(current_frame);
tomwalters@0 105
tomwalters@0 106 % start plotting:
tomwalters@0 107 % clf;
tomwalters@0 108 axis off
tomwalters@0 109 caxes=get(gca,'position');
tomwalters@0 110
tomwalters@0 111 channel_density=0.015; % passt für 76 channels von 100 bis 6000
tomwalters@0 112 % channel_density=2*0.015; % passt für 76 channels von 100 bis 6000
tomwalters@0 113 hoehe=getnrchannels(current_frame)*channel_density;
tomwalters@0 114 if hoehe>1
tomwalters@0 115 hoehe=1;
tomwalters@0 116 end
tomwalters@0 117 if hoehe < 0.2
tomwalters@0 118 hoehe = 0.2;
tomwalters@0 119 end
tomwalters@0 120
tomwalters@0 121 rect=[-0.04 0.15 0.9 hoehe*0.85];
tomwalters@0 122 rect(1:2)=caxes(1:2)+(rect(1:2).*caxes(3:4));
tomwalters@0 123 rect(3:4)=rect(3:4).*caxes(3:4);
tomwalters@0 124
tomwalters@0 125 hint=1; % this indicate that we dont want a title
tomwalters@0 126 mysubplot(1,1,1,rect, hint);
tomwalters@0 127 if options.oldhandle1~=0
tomwalters@0 128 delete(options.oldhandle1);
tomwalters@0 129 end
tomwalters@0 130 options.oldhandle1=gca;
tomwalters@0 131
tomwalters@0 132 plot_struct.t_min=minimum_time_interval/1000;
tomwalters@0 133 plot_struct.t_max=maximum_time_interval/1000;
tomwalters@0 134 plot_struct.has_axis=0;
tomwalters@0 135 plot_struct.is_log=is_log;
tomwalters@0 136 plot_struct.has_y_axis=0;
tomwalters@0 137 axis off
tomwalters@0 138
tomwalters@0 139 plot(current_frame,plot_struct);
tomwalters@0 140 set(gca,'zlim',[0 1/plot_scale]);
tomwalters@0 141
tomwalters@0 142 if show_time
tomwalters@0 143 srate=getsr(current_frame);
tomwalters@0 144 text_x=0.8*maximum_time_interval*srate/1000;
tomwalters@0 145 text_y=getnrchannels(current_frame)*1.1;
tomwalters@0 146 frame_number=getcurrentframenumber(current_frame);
tomwalters@0 147 frame_time=getcurrentframestarttime(current_frame);
tomwalters@0 148 text(text_x,text_y,sprintf('%3d : %4.0fms',frame_number,frame_time*1000),'FontSize',8);
tomwalters@0 149 % text(text_x,text_y,sprintf('%d',frame_number),'FontSize',8);
tomwalters@0 150 end
tomwalters@0 151
tomwalters@0 152 % interval sum
tomwalters@0 153 rect=[-0.04 0 0.9 0.2];
tomwalters@0 154 rect(1:2)=caxes(1:2)+(rect(1:2).*caxes(3:4));
tomwalters@0 155 rect(3:4)=rect(3:4).*caxes(3:4);
tomwalters@0 156 mysubplot(1,1,1,rect, hint);
tomwalters@0 157 if options.oldhandle2~=0
tomwalters@0 158 delete(options.oldhandle2);
tomwalters@0 159 end
tomwalters@0 160 options.oldhandle2=gca;
tomwalters@0 161
tomwalters@0 162 summe=getsum(current_frame); % here it is calculated
tomwalters@0 163 axis off
tomwalters@0 164
tomwalters@0 165 srate=getsr(current_frame);
tomwalters@0 166 if is_log
tomwalters@0 167 t=minimum_time_interval;
tomwalters@0 168 if t<=0
tomwalters@0 169 error('in logarithmic plots, the minimum time interval must be positiv!');
tomwalters@0 170 end
tomwalters@0 171 ti=[t 2*t 4*t 8*t 16*t 32*t 64*t];
tomwalters@0 172 tix=(ti)/1000*srate; % there shell be the tix
tomwalters@0 173 ti=(ti);
tomwalters@0 174 ti=round(ti*100)/100;
tomwalters@0 175 if getminimumtime(summe) <0
tomwalters@0 176 psumme=getpart(summe,getminimumtime(summe),0);
tomwalters@0 177 else
tomwalters@0 178 psumme=getpart(summe,getminimumtime(summe),maximum_time_interval/1000);
tomwalters@0 179 end
tomwalters@0 180 % rsumme=reverse(psumme);
tomwalters@0 181 rsumme=psumme;
tomwalters@0 182 sumvalues=getvalues(rsumme);
tomwalters@0 183 min_x_screen=minimum_time_interval/1000*srate; % thats the first point we want to see on the screen
tomwalters@0 184 max_x_screen=maximum_time_interval/1000*srate; % thats the first point we want to see on the screen
tomwalters@0 185 else % its not logarithmic!
tomwalters@0 186 frame_start_time=getminimumtime(current_frame);
tomwalters@0 187 if maximum_time_interval>0
tomwalters@0 188 summe=getpart(summe,(minimum_time_interval/1000+frame_start_time),maximum_time_interval/1000+frame_start_time);
tomwalters@0 189 else
tomwalters@0 190 summe=getpart(summe,(-maximum_time_interval/1000+frame_start_time),-minimum_time_interval/1000+frame_start_time);
tomwalters@0 191 end
tomwalters@0 192 nr_labels=8;
tomwalters@0 193 xbis=getnrpoints(summe);
tomwalters@0 194 tix=0:xbis/nr_labels:xbis;
tomwalters@0 195 xstep=(maximum_time_interval-minimum_time_interval)*1000/nr_labels; %works from -35 to 5
tomwalters@0 196 xstep=round(xstep);
tomwalters@0 197 ti=([minimum_time_interval*1000:xstep:maximum_time_interval*1000])/1000;
tomwalters@0 198 ti=round(ti*10)/10;
tomwalters@0 199 % sumvalues=getvalues(reverse(summe));
tomwalters@0 200 sumvalues=getvalues(summe);
tomwalters@0 201
tomwalters@0 202 min_x_screen=0;
tomwalters@0 203 max_x_screen=(maximum_time_interval-minimum_time_interval)/1000*srate; % thats the first point we want to see on the screen
tomwalters@0 204
tomwalters@0 205 end
tomwalters@0 206
tomwalters@0 207 h=plot(sumvalues); hold on
tomwalters@0 208 if scale_summe==0
tomwalters@0 209 axis([min_x_screen max_x_screen 0 1]);
tomwalters@0 210 else
tomwalters@0 211 axis([min_x_screen max_x_screen 0 scale_summe/time_profile_scale]);
tomwalters@0 212 end
tomwalters@0 213
tomwalters@0 214 % set(gca,'XDir','reverse') % turn them around, because the higher values shell end on the right
tomwalters@0 215 if is_log
tomwalters@0 216 set(gca,'XScale','log')
tomwalters@0 217 end
tomwalters@0 218
tomwalters@0 219 if time_reversed
tomwalters@0 220 ti=ti(end:-1:1);
tomwalters@0 221 end
tomwalters@0 222 set(gca,'XTick',tix);
tomwalters@0 223 set(gca,'XTickLabel',ti);
tomwalters@0 224 set(gca,'YTickLabel',[]);
tomwalters@0 225 %
tomwalters@0 226 if is_log
tomwalters@0 227 text(max_x_screen*0.5,-scale_summe/5,'time interval (ms)'); % this is at a nice position
tomwalters@0 228 else
tomwalters@0 229 text(500,-scale_summe/5,'time interval (ms)'); % this is at a nice position
tomwalters@0 230 end
tomwalters@0 231
tomwalters@0 232
tomwalters@0 233
tomwalters@0 234 % frequency sum
tomwalters@0 235 scale_frequency=getscalefrequency(current_frame);
tomwalters@0 236
tomwalters@0 237 hoehe=getnrchannels(current_frame)*channel_density;
tomwalters@0 238 if hoehe>1
tomwalters@0 239 hoehe=1;
tomwalters@0 240 end
tomwalters@0 241
tomwalters@0 242 rect=[0.856 0.19 0.1 hoehe*0.81];
tomwalters@0 243 rect(1:2)=caxes(1:2)+(rect(1:2).*caxes(3:4));
tomwalters@0 244 rect(3:4)=rect(3:4).*caxes(3:4);
tomwalters@0 245 mysubplot(1,1,1,rect, hint);
tomwalters@0 246 if options.oldhandle3~=0
tomwalters@0 247 delete(options.oldhandle3);
tomwalters@0 248 end
tomwalters@0 249 options.oldhandle3=gca;
tomwalters@0 250 fresumme=getfrequencysum(current_frame); % here it is calculated
tomwalters@0 251 % fresumme=smooth(fresumme,1);% glätte die Summe
tomwalters@0 252
tomwalters@0 253 % fresumme=fresumme/frequency_profile_scale;
tomwalters@0 254
tomwalters@0 255 fresumme=setname(fresumme,'');
tomwalters@0 256 fresumme=setunit_x(fresumme,'');
tomwalters@0 257 fresumme=setunit_y(fresumme,'');
tomwalters@0 258
tomwalters@0 259 plot(fresumme,'r'); hold on
tomwalters@0 260 v=getvalues(fresumme);
tomwalters@0 261 axis([0 size(v,1)*47/42 0 scale_frequency/frequency_profile_scale]);
tomwalters@0 262 view(-90,90);
tomwalters@0 263 % make y-Ticks
tomwalters@0 264 nr_labels=8;
tomwalters@0 265 nr_channels=getnrpoints(fresumme);
tomwalters@0 266 xstep=(nr_channels-1)/(nr_labels-1);
tomwalters@0 267 tix=1:xstep:nr_channels;
tomwalters@0 268 cfs=getcf(current_frame);
tomwalters@0 269 ti=cfs(floor(tix))/1000;
tomwalters@0 270 ti=round(ti*10)/10;
tomwalters@0 271 set(gca,'XTick',tix);
tomwalters@0 272 set(gca,'XTickLabel',ti);
tomwalters@0 273 set(gca,'YTickLabel',[]);
tomwalters@0 274 set(gca,'XAxisLocation','top');
tomwalters@0 275