annotate aim-mat/tools/@frame/plottemporalprofile.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 % method of class @frame
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
tomwalters@0 8 % (c) 2003, University of Cambridge, Medical Research Council
tomwalters@0 9 % Stefan Bleeck (stefan@bleeck.de)
tomwalters@0 10 % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual
tomwalters@0 11 % $Date: 2003/07/27 15:29:59 $
tomwalters@0 12 % $Revision: 1.12 $
tomwalters@0 13
tomwalters@0 14 function hand=plottemporalprofile(current_frame,options,ax)
tomwalters@0 15
tomwalters@0 16 if nargin <3
tomwalters@0 17 ax=gca;
tomwalters@0 18 end
tomwalters@0 19 if nargin <2
tomwalters@0 20 options=[];
tomwalters@0 21 end
tomwalters@0 22
tomwalters@0 23 start_time=getminimumtime(current_frame);
tomwalters@0 24 if start_time < 0 % these are frames read in from ams
tomwalters@0 25 % max_time=getmaximumtime(current_frame);
tomwalters@0 26 fr=getpart(current_frame,start_time,0);
tomwalters@0 27 current_frame=reverse(current_frame);
tomwalters@0 28 start_time=0;
tomwalters@0 29 current_frame=setstarttime(current_frame,0);
tomwalters@0 30 end
tomwalters@0 31
tomwalters@0 32
tomwalters@0 33
tomwalters@0 34 if ~isfield(options,'has_x_axis');
tomwalters@0 35 has_x_axis=1;
tomwalters@0 36 else
tomwalters@0 37 has_x_axis=options.has_x_axis;
tomwalters@0 38 end
tomwalters@0 39
tomwalters@0 40 if ~isfield(options,'is_log');
tomwalters@0 41 is_log=1;
tomwalters@0 42 else
tomwalters@0 43 is_log=options.is_log;
tomwalters@0 44 end
tomwalters@0 45
tomwalters@0 46 % for compatibility.
tomwalters@0 47 if isfield(options,'minimum_time');
tomwalters@0 48 options.minimum_time_interval=options.minimum_time;
tomwalters@0 49 end
tomwalters@0 50 if isfield(options,'maximum_time');
tomwalters@0 51 options.maximum_time_interval=options.maximum_time;
tomwalters@0 52 end
tomwalters@0 53
tomwalters@0 54 if ~isfield(options,'minimum_time_interval');
tomwalters@0 55 if is_log
tomwalters@0 56 minimum_time_interval=0.001;
tomwalters@0 57 else
tomwalters@0 58 minimum_time_interval=0;
tomwalters@0 59 end
tomwalters@0 60 else
tomwalters@0 61 minimum_time_interval=options.minimum_time_interval;
tomwalters@0 62 end
tomwalters@0 63
tomwalters@0 64 if isfield(options,'time_profile_scale');
tomwalters@0 65 time_profile_scale=options.time_profile_scale;
tomwalters@0 66 else
tomwalters@0 67 time_profile_scale=1;
tomwalters@0 68 end
tomwalters@0 69 % if the time scale is reversed (time from left to right)
tomwalters@0 70 if isfield(options,'time_reversed');
tomwalters@0 71 time_reversed=options.time_reversed;
tomwalters@0 72 else
tomwalters@0 73 time_reversed=0;
tomwalters@0 74 end
tomwalters@0 75
tomwalters@0 76 if ~isfield(options,'maximum_time_interval');
tomwalters@0 77 maximum_time_interval=0.035;
tomwalters@0 78 else
tomwalters@0 79 maximum_time_interval=options.maximum_time_interval;
tomwalters@0 80 end
tomwalters@0 81
tomwalters@0 82 % if maximum_time_interval>getmaximumtime(current_frame)
tomwalters@0 83 % maximum_time_interval=getmaximumtime(current_frame);
tomwalters@0 84 % end
tomwalters@0 85
tomwalters@0 86
tomwalters@0 87 scale_summe=getscalesumme(current_frame); %for scaling properties
tomwalters@0 88
tomwalters@0 89 % start plotting:
tomwalters@0 90 plot_struct.t_min=minimum_time_interval;
tomwalters@0 91 plot_struct.t_max=maximum_time_interval;
tomwalters@0 92 plot_struct.has_axis=0;
tomwalters@0 93 plot_struct.is_log=is_log;
tomwalters@0 94 plot_struct.has_y_axis=0;
tomwalters@0 95
tomwalters@0 96 % interval sum
tomwalters@0 97 % partframe=getpart(current_frame,minimum_time_interval,maximum_time_interval);
tomwalters@0 98 % summe=getsum(partframe); % here it is calculated
tomwalters@0 99 % axis off
tomwalters@0 100
tomwalters@0 101 sr=getsr(current_frame);
tomwalters@0 102 % start_time=getminimumtime(current_frame);
tomwalters@0 103 % sumvalues=getpart(summe,(minimum_time_interval+start_time),maximum_time_interval+start_time);
tomwalters@0 104 % min_x_screen=round(abs((minimum_time_interval-start_time+1/sr)*sr)); % thats the first point we want to see on the screen
tomwalters@0 105 % max_x_screen=round(abs((maximum_time_interval-start_time)*sr)); % thats the first point we want to see on the screen
tomwalters@0 106
tomwalters@0 107 start_time=getminimumtime(current_frame);
tomwalters@0 108 if is_log
tomwalters@0 109 min_x_screen=1;
tomwalters@0 110 max_x_screen=round(abs((maximum_time_interval-start_time)*sr)); % thats the first point we want to see on the screen
tomwalters@0 111 else
tomwalters@0 112 min_x_screen=round(abs((minimum_time_interval-start_time+1/sr)*sr)); % thats the first point we want to see on the screen
tomwalters@0 113 max_x_screen=round(abs((maximum_time_interval-start_time)*sr)); % thats the first point we want to see on the screen
tomwalters@0 114 end
tomwalters@0 115
tomwalters@0 116
tomwalters@0 117 if max_x_screen>getnrpoints(current_frame)
tomwalters@0 118 max_x_screen=getnrpoints(current_frame);
tomwalters@0 119 maximum_time_interval=(max_x_screen/sr)+start_time;
tomwalters@0 120 end
tomwalters@0 121
tomwalters@0 122
tomwalters@0 123 current_frame_values=getvalues(current_frame);
tomwalters@0 124 cvals=current_frame_values(:,min_x_screen:max_x_screen);
tomwalters@0 125
tomwalters@0 126 if getxaxis(current_frame)=='0'
tomwalters@0 127 cvals=cvals/1000;
tomwalters@0 128 end;
tomwalters@0 129
tomwalters@0 130 if size(cvals,1)==1
tomwalters@0 131 sumcvals=cvals;
tomwalters@0 132 else
tomwalters@0 133 sumcvals=sum(cvals)';
tomwalters@0 134 end
tomwalters@0 135 % cvals=getvalues(summe);
tomwalters@0 136 % min_x_screen=1;
tomwalters@0 137 % max_x_screen=size(cvals,1);
tomwalters@0 138 hand=plot(ax,sumcvals);
tomwalters@0 139
tomwalters@0 140 maxshowy=1.1;
tomwalters@0 141 if min(cvals) >= 0
tomwalters@0 142 minshowy=0;
tomwalters@0 143 else
tomwalters@0 144 minshowy=-1;
tomwalters@0 145 end
tomwalters@0 146
tomwalters@0 147 maxy=maxshowy*scale_summe/time_profile_scale;
tomwalters@0 148 if maxy==0
tomwalters@0 149 maxy=1;
tomwalters@0 150 end
tomwalters@0 151 if time_profile_scale==-1 % decide myself
tomwalters@0 152 maxy=1.2*max(sumcvals);
tomwalters@0 153 end
tomwalters@0 154
tomwalters@0 155 % save the two profiles to text files for further analysis
tomwalters@0 156 % 1: freq profile
tomwalters@0 157 x1=getcf(current_frame);
tomwalters@0 158 y1=sum(cvals');
bleeck@3 159 % x1=
bleeck@3 160 % A1=[x1' y1'];
tomwalters@0 161 % save freqp.txt A1 -ascii
bleeck@3 162 % dlmwrite('freqprofile.txt',A1, '\t')
tomwalters@0 163
tomwalters@0 164
tomwalters@0 165 % 2: temp profile
bleeck@3 166 % sr=getsr(current_frame);
bleeck@3 167 % x2=1000/sr:1000/sr:getlength(current_frame)*1000;
bleeck@3 168 % y2=sum(cvals);
bleeck@3 169 % A2=[x2' y2'];
tomwalters@0 170 % save tempp.txt A1 -ascii
tomwalters@0 171 % dlmwrite('tempprofile.txt',A2, '\t')
tomwalters@0 172
tomwalters@0 173
tomwalters@0 174
tomwalters@0 175
tomwalters@0 176
tomwalters@0 177 if is_log
tomwalters@0 178 min_x_screen=round(abs((minimum_time_interval-start_time+1/sr)*sr)); % thats the first point we want to see on the screen
tomwalters@0 179 if max_x_screen ==min_x_screen
tomwalters@0 180 max_x_screen =min_x_screen +1;
tomwalters@0 181 end
tomwalters@0 182 try
tomwalters@0 183 set(ax,'xlim',[min_x_screen max_x_screen]);
tomwalters@0 184 set(ax,'ylim',[minshowy maxy]);
tomwalters@0 185
tomwalters@0 186 % axis([min_x_screen max_x_screen minshowy maxy]);
tomwalters@0 187 end
tomwalters@0 188 if time_reversed
tomwalters@0 189 set(ax,'XDir','reverse') % turn them around, because the higher values shell end on the right
tomwalters@0 190 end
tomwalters@0 191 set(ax,'XScale','log')
tomwalters@0 192 t=minimum_time_interval;
tomwalters@0 193 ti=[t 2*t 4*t 8*t 16*t 32*t 64*t];
tomwalters@0 194 tix=(ti)*sr; % there shell be the tix
tomwalters@0 195 % tix(1)=tix(1)+1;
tomwalters@0 196 ti=(ti*1000);
tomwalters@0 197 ti=fround(ti,2);
tomwalters@0 198 else % its not logarithmic!
tomwalters@0 199 if time_reversed
tomwalters@0 200 set(ax,'XDir','reverse') % turn them around, because the higher values shell end on the right
tomwalters@0 201 else
tomwalters@0 202 set(ax,'XDir','normal') % normale ausrichtung
tomwalters@0 203 end
tomwalters@0 204 nrx=size(cvals,2);
tomwalters@0 205 if scale_summe==0
tomwalters@0 206 scale_summe=1;
tomwalters@0 207 end
tomwalters@0 208 axis([1 length(sumcvals) minshowy maxy]);
tomwalters@0 209 nr_labels=8;
tomwalters@0 210 tix=1:(nrx-1)/nr_labels:nrx;
tomwalters@0 211 xstep=(maximum_time_interval-minimum_time_interval)*1000/(nr_labels); %works from -35 to 5
tomwalters@0 212 ti=([minimum_time_interval*1000:xstep:maximum_time_interval*1000+1]);
tomwalters@0 213 ti=round(ti*10)/10;
tomwalters@0 214 set(ax,'XScale','linear')
tomwalters@0 215 % text(min_x_screen*1.5,-scale_summe/5,'Time (ms)'); % this is at a nice position
tomwalters@0 216 end
tomwalters@0 217
tomwalters@0 218 if has_x_axis
tomwalters@0 219 if max(tix)>1
tomwalters@0 220 set(ax,'XTick',tix);
tomwalters@0 221 set(ax,'XTickLabel',ti);
tomwalters@0 222 end
tomwalters@0 223 else
tomwalters@0 224 set(ax,'xtick',[]); % we dont want any z-Ticks!
tomwalters@0 225 end % axis
tomwalters@0 226
tomwalters@0 227 % if scale_summe==0
tomwalters@0 228 % axis([min_x_screen max_x_screen minshowy maxshowy]);
tomwalters@0 229 % else
tomwalters@0 230 % axis([min_x_screen max_x_screen minshowy maxshowy*scale_summe/time_profile_scale]);
tomwalters@0 231 % end
tomwalters@0 232
tomwalters@0 233 if getxaxis(current_frame)=='0'
tomwalters@0 234 d=size(cvals);
tomwalters@0 235 ti = [0:1:16];
tomwalters@0 236 step=(d(2)/16);
tomwalters@0 237 tix = [0:step:d(2)];
tomwalters@0 238 end;
tomwalters@0 239
tomwalters@0 240 % stefan for the scale profile
tomwalters@0 241 if strcmp(getxaxis(current_frame),'harmonic ratio')
tomwalters@0 242 ti=get(ax,'XTickLabel');
tomwalters@0 243 ti=str2num(ti)/1000;
tomwalters@0 244 end
tomwalters@0 245
tomwalters@0 246
tomwalters@0 247 set(ax,'XTick',tix);
tomwalters@0 248 set(ax,'XTickLabel',ti);
tomwalters@0 249 set(ax,'YTickLabel',[]);
tomwalters@0 250