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/01/17 16:57:46 $
|
tomwalters@0
|
12 % $Revision: 1.3 $
|
tomwalters@0
|
13
|
tomwalters@0
|
14 function ret=frequencysharpening(current_frame,options)
|
tomwalters@0
|
15 % frequency sharpening does local lateral inhibition according to its
|
tomwalters@0
|
16 % parameters
|
tomwalters@0
|
17
|
tomwalters@0
|
18
|
tomwalters@0
|
19 if nargin < 2
|
tomwalters@0
|
20 options=[];
|
tomwalters@0
|
21 end
|
tomwalters@0
|
22
|
tomwalters@0
|
23
|
tomwalters@0
|
24 if isfield(options,'excitatory_area') % how many erbs the excitation lasts
|
tomwalters@0
|
25 excitatory_area=options.excitatory_area;
|
tomwalters@0
|
26 else
|
tomwalters@0
|
27 excitatory_area=0.5;
|
tomwalters@0
|
28 end
|
tomwalters@0
|
29
|
tomwalters@0
|
30 if isfield(options,'grafix') % how many erbs the excitation lasts
|
tomwalters@0
|
31 grafix=options.grafix;
|
tomwalters@0
|
32 else
|
tomwalters@0
|
33 grafix=0;
|
tomwalters@0
|
34 end
|
tomwalters@0
|
35
|
tomwalters@0
|
36 if isfield(options,'inhibitory_area') % how many erbs the inhibition lasts
|
tomwalters@0
|
37 inhibitory_area=options.inhibitory_area;
|
tomwalters@0
|
38 else
|
tomwalters@0
|
39 inhibitory_area=1.5;
|
tomwalters@0
|
40 end
|
tomwalters@0
|
41
|
tomwalters@0
|
42 if isfield(options,'inhibitory_influence') % how strong the inhibition is
|
tomwalters@0
|
43 inhibitory_influence=options.inhibitory_influence;
|
tomwalters@0
|
44 else
|
tomwalters@0
|
45 inhibitory_influence=0.2;
|
tomwalters@0
|
46 end
|
tomwalters@0
|
47
|
tomwalters@0
|
48
|
tomwalters@0
|
49 cfs=getcf(current_frame);
|
tomwalters@0
|
50 EarQ = 9.26449; % Glasberg and Moore Parameters
|
tomwalters@0
|
51 minBW = 24.7;
|
tomwalters@0
|
52 order = 1;
|
tomwalters@0
|
53 ERB = ((cfs/EarQ).^order + minBW^order).^(1/order);
|
tomwalters@0
|
54 B=1.019*2*pi.*ERB;
|
tomwalters@0
|
55
|
tomwalters@0
|
56 vals=getvalues(current_frame);
|
tomwalters@0
|
57 nr_chan=size(vals,1);
|
tomwalters@0
|
58 nr_dots=size(vals,2);
|
tomwalters@0
|
59 new_vals=zeros(size(vals));
|
tomwalters@0
|
60
|
tomwalters@0
|
61 % calculate the interchannel crossinfluence for each channel
|
tomwalters@0
|
62 erb1=21.4*log10(4.73e-3*cfs(1)+1); % from Glasberg,Moore 1990
|
tomwalters@0
|
63 erb2=21.4*log10(4.73e-3*cfs(nr_chan)+1);
|
tomwalters@0
|
64 nr_erbs=erb2-erb1;
|
tomwalters@0
|
65 erb_density=nr_chan/nr_erbs;
|
tomwalters@0
|
66 neighbourinfluence=zeros(nr_chan);
|
tomwalters@0
|
67 if grafix
|
tomwalters@0
|
68 figure(2)
|
tomwalters@0
|
69 clf
|
tomwalters@0
|
70 end
|
tomwalters@0
|
71 for i=1:nr_chan % through all channels: prepare working variable
|
tomwalters@0
|
72 count=1;
|
tomwalters@0
|
73 for j=i-nr_chan:i+nr_chan % calculate the influence of all channels
|
tomwalters@0
|
74 if j>0 & j< nr_chan
|
tomwalters@0
|
75 dist=abs(i-j); % we are symmetric
|
tomwalters@0
|
76 disterbs=dist/erb_density; % so many erbs between the channel and me
|
tomwalters@0
|
77
|
tomwalters@0
|
78 % the function(disterbs) to describe the influence of
|
tomwalters@0
|
79 % neighbouring channels:
|
tomwalters@0
|
80 % final=1/disterbs;
|
tomwalters@0
|
81
|
tomwalters@0
|
82 % Mexican hat function:
|
tomwalters@0
|
83 % p=disterbs*disterbs/(threshold_decay_halflife*threshold_decay_halflife);
|
tomwalters@0
|
84 % version with power
|
tomwalters@0
|
85 % final=(2-p)*exp(-0.5*p);
|
tomwalters@0
|
86 % version with difference from gaussians:
|
tomwalters@0
|
87 p1=disterbs*disterbs/(excitatory_area*excitatory_area);
|
tomwalters@0
|
88 p2=disterbs*disterbs/(inhibitory_area*inhibitory_area);
|
tomwalters@0
|
89 final=exp(-p1)-inhibitory_influence*exp(-p2);
|
tomwalters@0
|
90
|
tomwalters@0
|
91 neighbourinfluence(i,count)=final;
|
tomwalters@0
|
92 count=count+1;
|
tomwalters@0
|
93 end
|
tomwalters@0
|
94 end
|
tomwalters@0
|
95 % normalize it
|
tomwalters@0
|
96 % scale=1/sum(neighbourinfluence(i,:));
|
tomwalters@0
|
97 % neighbourinfluence(i,:)=neighbourinfluence(i,:)*scale;
|
tomwalters@0
|
98 if grafix
|
tomwalters@0
|
99 figure(2)
|
tomwalters@0
|
100 plot(neighbourinfluence(i,:)); hold on
|
tomwalters@0
|
101 if i==30
|
tomwalters@0
|
102 plot(neighbourinfluence(i,:),'.-r','linewidth',3); hold on
|
tomwalters@0
|
103 end
|
tomwalters@0
|
104 end
|
tomwalters@0
|
105 end
|
tomwalters@0
|
106
|
tomwalters@0
|
107 for i=1:nr_dots % through the time
|
tomwalters@0
|
108 for j=1:nr_chan % through all channels: prepare working variable
|
tomwalters@0
|
109 new_vals(:,i)=new_vals(:,i)+vals(:,i).*neighbourinfluence(:,j);
|
tomwalters@0
|
110 end
|
tomwalters@0
|
111 end
|
tomwalters@0
|
112
|
tomwalters@0
|
113 s=getfrequencysum(current_frame);
|
tomwalters@0
|
114 current_frame=setvalues(current_frame,new_vals);
|
tomwalters@0
|
115
|
tomwalters@0
|
116 ret=current_frame;
|
tomwalters@0
|
117
|
tomwalters@0
|
118 if grafix
|
tomwalters@0
|
119 figure(3) ;clf;
|
tomwalters@0
|
120 s2=getfrequencysum(current_frame);
|
tomwalters@0
|
121 plot(s); hold on
|
tomwalters@0
|
122 ax=axis;
|
tomwalters@0
|
123 plot(s2,'.-r');
|
tomwalters@0
|
124 axis([0 58 0 40000]);
|
tomwalters@0
|
125 end
|