tomwalters@0: % Function for the calculation of the SSI tomwalters@0: % tomwalters@0: % INPUT VALUES: SAI3d : 3D SAI tomwalters@0: % NAPparam: Parameter for NAP tomwalters@0: % SAIparam: Parameter for SAI tomwalters@0: % SSIparam: Parameter for SSI tomwalters@0: % RETURN VALUE: SSI3d: 3D Size-Shape Image tomwalters@0: % tomwalters@0: % (c) 2003-2008, University of Cambridge, Medical Research Council tomwalters@0: % Original Code IRINO T, 10 Jan. 2002 tomwalters@0: % tomwalters@0: % Modified for the size shape image tomwalters@0: % Marc A. Al-Hames tomwalters@0: % April 2003 bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: tomwalters@0: tomwalters@0: function [SSI3d] = Calssi(SAI3d,options,sample_rate) tomwalters@0: tomwalters@0: SSIparam.NSAIPhsCmp = 0; tomwalters@0: SSIparam.F0mode = 300; tomwalters@0: SSIparam.TFval = options.TFval; tomwalters@0: SSIparam.c_2pi = options.c_2pi; tomwalters@0: Lenc2pi = length(SSIparam.c_2pi); tomwalters@0: LenTF = length(SSIparam.TFval); tomwalters@0: SSIparam.Mu = -0.5; % flat if Mu <0.5: high pass, Mu>0.5 low pass tomwalters@0: SAIparam.Nwidth = 0; %sets the negative width of the window tomwalters@0: tomwalters@0: [NumCh, LenSAI, LenFrame] = size(SAI3d); tomwalters@0: tomwalters@0: %here we set up the Frs values for each channel tomwalters@0: if isfield(options, 'lowest_frequency') tomwalters@0: fre1=options.lowest_frequency; tomwalters@0: else tomwalters@0: fre1=100; tomwalters@0: end tomwalters@0: if isfield(options, 'highest_frequency') tomwalters@0: fre2=options.highest_frequency; tomwalters@0: else tomwalters@0: fre2=6000; tomwalters@0: end tomwalters@0: cf_afb = [fre1 fre2]; tomwalters@0: NAPparam.Frs = FcNch2EqERB(min(cf_afb),max(cf_afb),NumCh); tomwalters@0: NAPparam.fs = sample_rate; tomwalters@0: tomwalters@0: %We initialise the SSI matrix tomwalters@0: SSI3d = zeros(NumCh,LenTF,LenFrame); tomwalters@0: tomwalters@0: waithand=waitbar(0,'generating the SSI'); tomwalters@0: tomwalters@0: % set the frame range, the SSI is calculated for tomwalters@0: if (options.do_all_frames == 1) tomwalters@0: start_frame = 1; tomwalters@0: end_frame = LenFrame; tomwalters@0: else tomwalters@0: start_frame = options.framerange(1); tomwalters@0: end_frame = options.framerange(2); tomwalters@0: end; tomwalters@0: tomwalters@0: %this section does the filter response alignment tomwalters@0: for nfr = start_frame:end_frame tomwalters@0: %set up the waitbar tomwalters@0: fraction_complete=nfr/LenFrame; tomwalters@0: waitbar(fraction_complete); tomwalters@0: tomwalters@0: %generate the new matricies of the frames tomwalters@0: SAIval = SAI3d(:,:,nfr); tomwalters@0: SAIPhsCmp = zeros(size(SAIval)); tomwalters@0: tomwalters@0: %we shift each channel along the time interval axis by adding zeros tomwalters@0: for nch = 1:NumCh, tomwalters@0: NPeriod = NAPparam.fs/NAPparam.Frs(nch) * SSIparam.NSAIPhsCmp; tomwalters@0: shift_matrix = [zeros(1,fix(NPeriod)), SAIval(nch,:)]; tomwalters@0: SAIPhsCmp(nch,1:LenSAI) = shift_matrix(1:LenSAI); tomwalters@0: end; tomwalters@0: if SSIparam.F0mode == 0 tomwalters@0: else tomwalters@0: F0est(nfr) = SSIparam.F0mode; tomwalters@0: end; tomwalters@0: tomwalters@0: %Here we extract the information required to ensure that we have tomwalters@0: %only one presentation of the 'timbre' information tomwalters@0: ZeroLoc = abs(SAIparam.Nwidth)*NAPparam.fs/1000+1; tomwalters@0: MarginAF = 0; % No margin by introducing WinAF tomwalters@0: tomwalters@0: % set the range for the auditory image tomwalters@0: if (options.do_all_image == 1) tomwalters@0: SSIparam.RangeAudFig = [1 LenSAI]; tomwalters@0: else tomwalters@0: SSIparam.RangeAudFig = options.audiorange; tomwalters@0: end; tomwalters@0: % maah: was MIparam.RangeAudFig = [ZeroLoc+[0 , (fix(NAPparam.fs/F0est(nfr))-MarginAF)]]; tomwalters@0: tomwalters@0: % Calculation of the SSI tomwalters@0: [SSImtrx] = Calssicoef(SAIPhsCmp,NAPparam,SSIparam); tomwalters@0: tomwalters@0: %Output into the 3d matrix tomwalters@0: SSI3d(:,:,nfr) = SSImtrx; tomwalters@0: tomwalters@0: end; tomwalters@0: tomwalters@0: close(waithand);