tomwalters@0: % tester generating function for Calculation of the Mellin Image in 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: SAI3d : 3D SAI tomwalters@0: % NAPparam: Parameter for NAP tomwalters@0: % SAIparam: Parameter for SAI tomwalters@0: % MIparam: Parameter for MI tomwalters@0: % RETURN VALUE: tomwalters@0: % MI3d: 3D Mellin Image tomwalters@0: % tomwalters@0: % (c) 2003, University of Cambridge, Medical Research Council tomwalters@0: % Original Code IRINO T tomwalters@0: % 10 Jan. 2002 tomwalters@0: % Modified by R. Turner (ret26@cam.ac.uk) tomwalters@0: % Feb. 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 [MI3d] = CalMI_Rich(SAI3d,options,sample_rate) tomwalters@0: tomwalters@0: %here we setup all the variables that the function requires tomwalters@0: %%% CHANGE THE NAMES SO IT'S CLEAR WHAT'S GOING ON!!! tomwalters@0: tomwalters@0: %what do these do? tomwalters@0: MIparam.NSAIPhsCmp = 0; %was 2 but aim uses a window starting at 0ms tomwalters@0: MIparam.F0mode = 300; tomwalters@0: tomwalters@0: %these values set the resolution and scale of the axes in the final MT tomwalters@0: %they are now defined in the parameter file tomwalters@0: MIparam.TFval = options.TFval; tomwalters@0: MIparam.c_2pi = options.c_2pi; tomwalters@0: Lenc2pi = length(MIparam.c_2pi); tomwalters@0: LenTF = length(MIparam.TFval); tomwalters@0: tomwalters@0: %not sure what these do tomwalters@0: MIparam.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: MIparam.SSI = options.ssi; tomwalters@0: tomwalters@0: %we find the maximum temporal interval size, the no of channels and the no tomwalters@0: %of frames tomwalters@0: [NumCh, LenSAI, LenFrame] = size(SAI3d); tomwalters@0: tomwalters@0: %going to remove any information in the first N channels tomwalters@0: % N=5; tomwalters@0: % for no_ch = 1:N, tomwalters@0: % SAI3d(no_ch,:,:)=zeros(LenSAI,LenFrame); tomwalters@0: % end; tomwalters@0: tomwalters@0: %saving the SAI3d for comparison with irino's tomwalters@0: % savefile = 'SAI3d_AIM.mat'; tomwalters@0: % SAI3d_AIM=SAI3d/max(max(max(SAI3d))); tomwalters@0: % save(savefile,'SAI3d_AIM'); tomwalters@0: tomwalters@0: %for using irino's SAI in AIM tomwalters@0: % load SAI3d_Irino.mat; tomwalters@0: % SAI3d=SAI3d_Irino; tomwalters@0: tomwalters@0: %here we set up the Frs values for each channel tomwalters@0: cf_afb = [100 6000]; %4500]; altered for 2dAT 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 mellin image matrix (why is it best to do this - is it tomwalters@0: %so we can spot errors more easily? tomwalters@0: MI3d = zeros(Lenc2pi,LenTF,LenFrame); tomwalters@0: tomwalters@0: %user information (commented out) + new wait bar tomwalters@0: %disp('*** MI Calculation ***'); tomwalters@0: tomwalters@0: %MIparam.RangeAudFig = []; tomwalters@0: %disp(MIparam); tomwalters@0: waithand=waitbar(0,'generating the MT'); tomwalters@0: tomwalters@0: % set the frame range, the mellin image 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: 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) * MIparam.NSAIPhsCmp; tomwalters@0: shift_matrix = [zeros(1,fix(NPeriod)), SAIval(nch,:)]; tomwalters@0: SAIPhsCmp(nch,1:LenSAI) = shift_matrix(1:LenSAI); tomwalters@0: %MI3d(:,:,nfr) = SAIPhsCmp'; %added line tomwalters@0: %SAIPhsCmp = SAI3d(:,:,nfr); %tester line tomwalters@0: end; tomwalters@0: if MIparam.F0mode == 0 tomwalters@0: % No estimation of F0 tomwalters@0: else tomwalters@0: F0est(nfr) = MIparam.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: % maah: set the range for the auditory image tomwalters@0: if (options.do_all_image == 1) tomwalters@0: MIparam.RangeAudFig = [1 LenSAI]; tomwalters@0: else tomwalters@0: MIparam.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 Mellin Coefficients tomwalters@0: [MImtrx] = CalMellinCoef_Rich(SAIPhsCmp,NAPparam,MIparam); tomwalters@0: tomwalters@0: %Output into the 3d matrix tomwalters@0: MI3d(1:Lenc2pi,1:LenTF,nfr) = MImtrx; tomwalters@0: tomwalters@0: % maah: Magnitude tomwalters@0: MI3d(1:Lenc2pi,1:LenTF,nfr) = abs(MI3d(1:Lenc2pi,1:LenTF,nfr)); tomwalters@0: %MI3d(:,:,nfr) = MImtrx; %added line tomwalters@0: tomwalters@0: end; tomwalters@0: tomwalters@0: close(waithand);