annotate aim-mat/tools/@frame/plotfrequencyprofile.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 74dedb26614d
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/10/21 14:14:02 $
tomwalters@0 12 % $Revision: 1.9 $
tomwalters@0 13
tomwalters@0 14 function hand=plotfrequencyprofile(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 if isfield(options,'frequency_profile_scale');
tomwalters@0 33 frequency_profile_scale=options.frequency_profile_scale;
tomwalters@0 34 else
tomwalters@0 35 frequency_profile_scale=1;
tomwalters@0 36 end
tomwalters@0 37
tomwalters@0 38 %shrink_range indicates, if the axis should not occupy the whole space
tomwalters@0 39 if isfield(options,'shrink_range');
tomwalters@0 40 shrink_range=options.shrink_range;
tomwalters@0 41 else
tomwalters@0 42 shrink_range=1;
tomwalters@0 43 end
tomwalters@0 44
tomwalters@0 45 if ~isfield(options,'minimum_time_interval');
tomwalters@0 46 minimum_time_interval=0;
tomwalters@0 47 else
tomwalters@0 48 minimum_time_interval=options.minimum_time_interval;
tomwalters@0 49 end
tomwalters@0 50
tomwalters@0 51 if ~isfield(options,'maximum_time_interval');
tomwalters@0 52 maximum_time_interval=0.035;
tomwalters@0 53 else
tomwalters@0 54 maximum_time_interval=options.maximum_time_interval;
tomwalters@0 55 end
tomwalters@0 56
tomwalters@0 57 if maximum_time_interval>getmaximumtime(current_frame)
tomwalters@0 58 maximum_time_interval=getmaximumtime(current_frame);
tomwalters@0 59 end
tomwalters@0 60
tomwalters@0 61
tomwalters@0 62 if ~isfield(options,'turn_axis_vertically');
tomwalters@0 63 turn_axis_vertically=1;
tomwalters@0 64 else
tomwalters@0 65 turn_axis_vertically=options.turn_axis_vertically;
tomwalters@0 66 end
tomwalters@0 67
tomwalters@0 68
tomwalters@0 69 % frequency sum
tomwalters@0 70 scale_frequency=getscalefrequency(current_frame);
tomwalters@0 71
tomwalters@0 72 % channel_density=0.015; % passt für 76 channels von 100 bis 6000
tomwalters@0 73 % hoehe=getnrchannels(current_frame)*channel_density;
tomwalters@0 74 % if hoehe>1
tomwalters@0 75 % hoehe=1;
tomwalters@0 76 % end
tomwalters@0 77 %
tomwalters@0 78 % rect=[0.856 0.19 0.1 hoehe*0.81];
tomwalters@0 79 % rect(1:2)=caxes(1:2)+(rect(1:2).*caxes(3:4));
tomwalters@0 80 % rect(3:4)=rect(3:4).*caxes(3:4);
tomwalters@0 81 % mysubplot(1,1,1,rect, hint);
tomwalters@0 82
tomwalters@0 83 part_current_frame=getpart(current_frame,minimum_time_interval,maximum_time_interval);
tomwalters@0 84 % if getxaxis(current_frame)=='0'
tomwalters@0 85 % h_cutoff=3;
tomwalters@0 86 % h_width=20;
tomwalters@0 87 % aa=getvalues(part_current_frame);
tomwalters@0 88 % aa=aa(1:601,h_cutoff*h_width:121);
tomwalters@0 89 % part_current_frame=frame(aa/100);
tomwalters@0 90 % end;
tomwalters@0 91
tomwalters@0 92 fresumme=getfrequencysum(part_current_frame); % here it is calculated
tomwalters@0 93 % fresumme=smooth(fresumme,1);% glätte die Summe
tomwalters@0 94 if getxaxis(current_frame)=='0'
tomwalters@0 95 [band_location band_height]=getlocalmaxima(fresumme);
tomwalters@0 96 band_location=(band_location/601)*30;
tomwalters@0 97 band_information(:,1)=band_location';
tomwalters@0 98 band_information(:,2)=band_height';
tomwalters@0 99 % disp('maxima');
tomwalters@0 100 % disp(' h val height');
tomwalters@0 101 % disp(band_information);
tomwalters@0 102 [min_posit min_height]=getlocalminima(fresumme);
tomwalters@0 103 min_posit=(min_posit/601)*30;
tomwalters@0 104 band_information2(:,1)=min_posit';
tomwalters@0 105 band_information2(:,2)=min_height';
tomwalters@0 106 % disp('minima');
tomwalters@0 107 % disp(' h val height');
tomwalters@0 108 % disp(band_information2);
tomwalters@0 109 end;
tomwalters@0 110
tomwalters@0 111
tomwalters@0 112 if frequency_profile_scale < 0
tomwalters@0 113 mscal=max(fresumme);
tomwalters@0 114 if mscal~=0
tomwalters@0 115 frequency_profile_scale=scale_frequency/mscal*0.9;
tomwalters@0 116 else
tomwalters@0 117 frequency_profile_scale=1;
tomwalters@0 118 end
tomwalters@0 119 end
tomwalters@0 120
tomwalters@0 121 fresumme=setname(fresumme,'');
tomwalters@0 122 fresumme=setunit_x(fresumme,'');
tomwalters@0 123 fresumme=setunit_y(fresumme,'');
tomwalters@0 124
tomwalters@0 125 % hand=plot(fresumme,'r'); hold on
tomwalters@0 126 v=getvalues(fresumme);
tomwalters@0 127 hand=plot(ax,v,'r'); hold on
tomwalters@0 128
tomwalters@0 129 maxy=scale_frequency/frequency_profile_scale;
tomwalters@0 130 if maxy==0
tomwalters@0 131 maxy=1;
tomwalters@0 132 end
tomwalters@0 133 nr=size(v,1);
tomwalters@0 134 if nr==0
tomwalters@0 135 nr=1;
tomwalters@0 136 end
tomwalters@0 137 set(ax,'xlim',[0 nr *shrink_range]);
tomwalters@0 138 set(ax,'ylim',[0 maxy]);
tomwalters@0 139
tomwalters@0 140 % axis([0 nr *shrink_range 0 maxy]);
tomwalters@0 141
tomwalters@0 142 if turn_axis_vertically==1
tomwalters@0 143 view(ax,-90,90);
tomwalters@0 144 end
tomwalters@0 145
tomwalters@0 146
tomwalters@0 147 % make y-Ticks
tomwalters@0 148 cfs=getcf(current_frame);
tomwalters@0 149 if length(cfs) > 1
tomwalters@0 150 nr_labels=8;
tomwalters@0 151 nr_channels=getnrpoints(fresumme);
tomwalters@0 152 xstep=(nr_channels-1)/(nr_labels-1);
tomwalters@0 153 tix=1:xstep:nr_channels;
tomwalters@0 154 ti=cfs(floor(tix))/1000;
tomwalters@0 155 else
tomwalters@0 156 ti=cfs;
tomwalters@0 157 tix=0.5;
tomwalters@0 158 end
tomwalters@0 159 ti=round(ti*10)/10;
tomwalters@0 160
tomwalters@0 161 if getxaxis(current_frame)=='0'
tomwalters@0 162 d=size(cfs);
tomwalters@0 163 ti = [0:5:30];
tomwalters@0 164 step=(d(2)/6);
tomwalters@0 165 tix = [0:step:d(2)];
tomwalters@0 166 end;
tomwalters@0 167
tomwalters@0 168 set(ax,'XTick',tix);
tomwalters@0 169 set(ax,'XTickLabel',ti);
tomwalters@0 170 if turn_axis_vertically==1
tomwalters@0 171 set(ax,'YTickLabel',[]);
tomwalters@0 172 set(ax,'XAxisLocation','top');
tomwalters@0 173 end
tomwalters@0 174