annotate matlab/bmm/carfac/MultiScaleSmooth.m @ 474:3a873d04a7fe

A few straggling fixes for binaural files
author dicklyon@google.com
date Fri, 16 Mar 2012 04:31:56 +0000
parents 87699cb4cf71
children 52f659be9008
rev   line source
tom@455 1 % Copyright 2012, Google, Inc.
tom@455 2 % Author: Richard F. Lyon
tom@455 3 %
tom@455 4 % This Matlab file is part of an implementation of Lyon's cochlear model:
tom@455 5 % "Cascade of Asymmetric Resonators with Fast-Acting Compression"
tom@455 6 % to supplement Lyon's upcoming book "Human and Machine Hearing"
tom@455 7 %
tom@455 8 % Licensed under the Apache License, Version 2.0 (the "License");
tom@455 9 % you may not use this file except in compliance with the License.
tom@455 10 % You may obtain a copy of the License at
tom@455 11 %
tom@455 12 % http://www.apache.org/licenses/LICENSE-2.0
tom@455 13 %
tom@455 14 % Unless required by applicable law or agreed to in writing, software
tom@455 15 % distributed under the License is distributed on an "AS IS" BASIS,
tom@455 16 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tom@455 17 % See the License for the specific language governing permissions and
tom@455 18 % limitations under the License.
tom@455 19
tom@455 20 function MultiScaleSmooth(waves, n_scales)
tom@455 21 % function MultiScaleSmooth(waves, n_scales)
tom@455 22 %
tom@455 23 % Let's take columns as waveforms, and smooth them to different scales;
tom@455 24 % these inputs can be carfac NAPs, for example, and the peaks of the
tom@455 25 % smoothed versions can be used as trigger events, even tracking back
tom@455 26 % to less-smoothed versions.
tom@455 27 % And we'll deciamte 2:1 at every other smoothing.
tom@455 28 %
tom@455 29 % Until we decide what we want, we'll just plot things, one plot per scale.
tom@455 30
tom@455 31 fig_offset1 = 10;
tom@455 32 fig_offset2 = 30;
tom@455 33 fig_offset3 = 50;
tom@455 34
tom@455 35 if nargin < 2
tom@455 36 n_scales = 20;
tom@455 37 end
tom@455 38
tom@455 39 smoothed = waves;
tom@455 40
tom@455 41 for scale_no = 1:n_scales
tom@455 42
tom@455 43 if mod(scale_no, 2) == 1
tom@455 44 newsmoothed = filter([1, 1]/2, 1, smoothed);
tom@455 45 diffsmoothed = max(0, smoothed - newsmoothed);
tom@455 46 smoothed = newsmoothed;
tom@455 47 else
tom@455 48 newsmoothed = filter([1, 2, 1]/4, 1, smoothed);
tom@455 49 diffsmoothed = max(0, smoothed - newsmoothed);
tom@455 50 smoothed = newsmoothed(1:2:end, :);
tom@455 51 end
tom@455 52
tom@455 53 figure(scale_no + fig_offset1)
dicklyon@462 54 imagesc(squeeze(smoothed(:,:,1))')
tom@455 55
tom@455 56 figure(scale_no + fig_offset2)
dicklyon@462 57 plot(squeeze(mean(smoothed, 2)));
tom@455 58
tom@455 59 drawnow
tom@455 60 pause(1)
tom@455 61
tom@455 62 end
tom@455 63
tom@455 64
tom@455 65 function waves = deskew(waves)
tom@455 66
tom@455 67 for col = 1:size(waves, 2)
tom@455 68 waves(1:(end-col+1), col) = waves(col:end, col);
tom@455 69 end
tom@455 70