annotate aim-mat/modules/usermodule/sst/Calssi.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 % Function for the calculation of the SSI
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES: SAI3d : 3D SAI
tomwalters@0 4 % NAPparam: Parameter for NAP
tomwalters@0 5 % SAIparam: Parameter for SAI
tomwalters@0 6 % SSIparam: Parameter for SSI
tomwalters@0 7 % RETURN VALUE: SSI3d: 3D Size-Shape Image
tomwalters@0 8 %
tomwalters@0 9 % (c) 2003-2008, University of Cambridge, Medical Research Council
tomwalters@0 10 % Original Code IRINO T, 10 Jan. 2002
tomwalters@0 11 %
tomwalters@0 12 % Modified for the size shape image
tomwalters@0 13 % Marc A. Al-Hames
tomwalters@0 14 % April 2003
bleeck@3 15 % (c) 2011, University of Southampton
bleeck@3 16 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 17 % download of current version is on the soundsoftware site:
bleeck@3 18 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 19 % documentation and everything is on http://www.acousticscale.org
bleeck@3 20
tomwalters@0 21
tomwalters@0 22 function [SSI3d] = Calssi(SAI3d,options,sample_rate)
tomwalters@0 23
tomwalters@0 24 SSIparam.NSAIPhsCmp = 0;
tomwalters@0 25 SSIparam.F0mode = 300;
tomwalters@0 26 SSIparam.TFval = options.TFval;
tomwalters@0 27 SSIparam.c_2pi = options.c_2pi;
tomwalters@0 28 Lenc2pi = length(SSIparam.c_2pi);
tomwalters@0 29 LenTF = length(SSIparam.TFval);
tomwalters@0 30 SSIparam.Mu = -0.5; % flat if Mu <0.5: high pass, Mu>0.5 low pass
tomwalters@0 31 SAIparam.Nwidth = 0; %sets the negative width of the window
tomwalters@0 32
tomwalters@0 33 [NumCh, LenSAI, LenFrame] = size(SAI3d);
tomwalters@0 34
tomwalters@0 35 %here we set up the Frs values for each channel
tomwalters@0 36 if isfield(options, 'lowest_frequency')
tomwalters@0 37 fre1=options.lowest_frequency;
tomwalters@0 38 else
tomwalters@0 39 fre1=100;
tomwalters@0 40 end
tomwalters@0 41 if isfield(options, 'highest_frequency')
tomwalters@0 42 fre2=options.highest_frequency;
tomwalters@0 43 else
tomwalters@0 44 fre2=6000;
tomwalters@0 45 end
tomwalters@0 46 cf_afb = [fre1 fre2];
tomwalters@0 47 NAPparam.Frs = FcNch2EqERB(min(cf_afb),max(cf_afb),NumCh);
tomwalters@0 48 NAPparam.fs = sample_rate;
tomwalters@0 49
tomwalters@0 50 %We initialise the SSI matrix
tomwalters@0 51 SSI3d = zeros(NumCh,LenTF,LenFrame);
tomwalters@0 52
tomwalters@0 53 waithand=waitbar(0,'generating the SSI');
tomwalters@0 54
tomwalters@0 55 % set the frame range, the SSI is calculated for
tomwalters@0 56 if (options.do_all_frames == 1)
tomwalters@0 57 start_frame = 1;
tomwalters@0 58 end_frame = LenFrame;
tomwalters@0 59 else
tomwalters@0 60 start_frame = options.framerange(1);
tomwalters@0 61 end_frame = options.framerange(2);
tomwalters@0 62 end;
tomwalters@0 63
tomwalters@0 64 %this section does the filter response alignment
tomwalters@0 65 for nfr = start_frame:end_frame
tomwalters@0 66 %set up the waitbar
tomwalters@0 67 fraction_complete=nfr/LenFrame;
tomwalters@0 68 waitbar(fraction_complete);
tomwalters@0 69
tomwalters@0 70 %generate the new matricies of the frames
tomwalters@0 71 SAIval = SAI3d(:,:,nfr);
tomwalters@0 72 SAIPhsCmp = zeros(size(SAIval));
tomwalters@0 73
tomwalters@0 74 %we shift each channel along the time interval axis by adding zeros
tomwalters@0 75 for nch = 1:NumCh,
tomwalters@0 76 NPeriod = NAPparam.fs/NAPparam.Frs(nch) * SSIparam.NSAIPhsCmp;
tomwalters@0 77 shift_matrix = [zeros(1,fix(NPeriod)), SAIval(nch,:)];
tomwalters@0 78 SAIPhsCmp(nch,1:LenSAI) = shift_matrix(1:LenSAI);
tomwalters@0 79 end;
tomwalters@0 80 if SSIparam.F0mode == 0
tomwalters@0 81 else
tomwalters@0 82 F0est(nfr) = SSIparam.F0mode;
tomwalters@0 83 end;
tomwalters@0 84
tomwalters@0 85 %Here we extract the information required to ensure that we have
tomwalters@0 86 %only one presentation of the 'timbre' information
tomwalters@0 87 ZeroLoc = abs(SAIparam.Nwidth)*NAPparam.fs/1000+1;
tomwalters@0 88 MarginAF = 0; % No margin by introducing WinAF
tomwalters@0 89
tomwalters@0 90 % set the range for the auditory image
tomwalters@0 91 if (options.do_all_image == 1)
tomwalters@0 92 SSIparam.RangeAudFig = [1 LenSAI];
tomwalters@0 93 else
tomwalters@0 94 SSIparam.RangeAudFig = options.audiorange;
tomwalters@0 95 end;
tomwalters@0 96 % maah: was MIparam.RangeAudFig = [ZeroLoc+[0 , (fix(NAPparam.fs/F0est(nfr))-MarginAF)]];
tomwalters@0 97
tomwalters@0 98 % Calculation of the SSI
tomwalters@0 99 [SSImtrx] = Calssicoef(SAIPhsCmp,NAPparam,SSIparam);
tomwalters@0 100
tomwalters@0 101 %Output into the 3d matrix
tomwalters@0 102 SSI3d(:,:,nfr) = SSImtrx;
tomwalters@0 103
tomwalters@0 104 end;
tomwalters@0 105
tomwalters@0 106 close(waithand);