tomwalters@0: % procedure for 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % paramfile : the name of a m-file with all relevant parameters for the project tomwalters@0: % OR: the name of an struct with all relevant information tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % result : the output of the last stage in the parameter file tomwalters@0: % tomwalters@0: % aim_ng (aim no graphic) calculates aim up to the stage of that is indicated tomwalters@0: % by the parameters in the file tomwalters@0: % tomwalters@0: % (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: bleeck@3: tomwalters@0: tomwalters@0: function result=aim_ng(paramfile) tomwalters@0: tomwalters@0: if isstruct(paramfile) tomwalters@0: all_options=paramfile; tomwalters@0: else tomwalters@0: olddir=pwd; tomwalters@0: [pathstr,name,ext] = fileparts(paramfile); tomwalters@0: if ~isempty(pathstr) tomwalters@0: cd(pathstr); tomwalters@0: end tomwalters@0: try tomwalters@0: eval(name); % evaluate the parameter file. Afterwards we have a set of parameters (hopefully in all_options) bleeck@3: cd(olddir); tomwalters@0: catch tomwalters@0: str=sprintf('The parameter file %s.m produced errors!',name); tomwalters@0: er=errordlg(str,'File Error'); tomwalters@0: set(er,'WindowStyle','modal'); tomwalters@0: pause; tomwalters@0: result=0; tomwalters@0: cd olddir; tomwalters@0: return tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: handles=[]; tomwalters@0: if isstruct(paramfile) tomwalters@0: if isfield(paramfile,'graphics') tomwalters@0: handles.all_options.graphics=paramfile.graphics; tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: % signalname: tomwalters@0: signame=all_options.signal.signal_filename; tomwalters@0: tomwalters@0: % set up all names, in case we need them: tomwalters@0: handles=setupnames(handles,signame); tomwalters@0: tomwalters@0: % no graphic please! tomwalters@0: handles.with_graphic=0; tomwalters@0: tomwalters@0: % in the no graphic version, do not store the results tomwalters@0: handles.info.save_signal=0; tomwalters@0: handles.info.save_pcp=0; tomwalters@0: handles.info.save_bmm=0; tomwalters@0: handles.info.save_nap=0; tomwalters@0: handles.info.save_strobes=0; tomwalters@0: handles.info.save_sai=0; tomwalters@0: handles.info.save_usermodule=0; tomwalters@0: handles.info.save_movie=0; tomwalters@0: % default values tomwalters@0: handles.info.calculate_signal=0; tomwalters@0: handles.info.calculate_pcp=0; tomwalters@0: handles.info.calculate_bmm=0; tomwalters@0: handles.info.calculate_nap=0; tomwalters@0: handles.info.calculate_strobes=0; tomwalters@0: handles.info.calculate_sai=0; tomwalters@0: handles.info.calculate_usermodule=0; tomwalters@0: handles.info.calculate_movie=0; tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: % first load the signal, that must be there! tomwalters@0: sigfile=all_options.signal.signal_filename; tomwalters@0: % where=strfind(sigfile,'.wav'); tomwalters@0: % handles.info.uniqueworkingname=sigfile(1:where-1); tomwalters@0: tomwalters@0: handles.all_options.signal=all_options.signal; tomwalters@0: sig=loadwavefile(signal,sigfile); tomwalters@0: handles.data.signal=sig; tomwalters@0: handles.data.original_signal=sig; tomwalters@0: tomwalters@0: % now find out, which column we want to calculate: tomwalters@0: if isfield(all_options,'pcp') tomwalters@0: handles.info.calculate_pcp=1; tomwalters@0: module_names=fieldnames(all_options.pcp); % find out, which module name tomwalters@0: module_name=module_names{1}; % only the first one is relevant! tomwalters@0: handles.info.current_pcp_module=module_name; % this one is the current one tomwalters@0: handles.all_options.pcp=all_options.pcp; % copy the parameters in place tomwalters@0: end tomwalters@0: if isfield(all_options,'bmm') tomwalters@0: handles.info.calculate_bmm=1; tomwalters@0: module_names=fieldnames(all_options.bmm); % find out, which module name tomwalters@0: module_name=module_names{1}; % only the first one is relevant! tomwalters@0: handles.info.current_bmm_module=module_name; % this one is the current one tomwalters@0: handles.all_options.bmm=all_options.bmm; % copy the parameters in place tomwalters@0: end tomwalters@0: if isfield(all_options,'nap') tomwalters@0: handles.info.calculate_nap=1; tomwalters@0: module_names=fieldnames(all_options.nap); % find out, which module name tomwalters@0: module_name=module_names{1}; % only the first one is relevant! tomwalters@0: handles.info.current_nap_module=module_name; % this one is the current one tomwalters@0: handles.all_options.nap=all_options.nap; % copy the parameters in place tomwalters@0: end tomwalters@0: if isfield(all_options,'strobes') tomwalters@0: handles.info.calculate_strobes=1; tomwalters@0: module_names=fieldnames(all_options.strobes); % find out, which module name tomwalters@0: module_name=module_names{1}; % only the first one is relevant! tomwalters@0: handles.info.current_strobes_module=module_name; % this one is the current one tomwalters@0: handles.all_options.strobes=all_options.strobes; % copy the parameters in place tomwalters@0: end tomwalters@0: if isfield(all_options,'sai') tomwalters@0: handles.info.calculate_sai=1; tomwalters@0: module_names=fieldnames(all_options.sai); % find out, which module name tomwalters@0: module_name=module_names{1}; % only the first one is relevant! tomwalters@0: handles.info.current_sai_module=module_name; % this one is the current one tomwalters@0: handles.all_options.sai=all_options.sai; % copy the parameters in place tomwalters@0: end tomwalters@0: if isfield(all_options,'usermodule') tomwalters@0: handles.info.calculate_usermodule=1; tomwalters@0: module_names=fieldnames(all_options.usermodule); % find out, which module name tomwalters@0: module_name=module_names{1}; % only the first one is relevant! tomwalters@0: handles.info.current_usermodule_module=module_name; % this one is the current one tomwalters@0: handles.all_options.usermodule=all_options.usermodule; % copy the parameters in place tomwalters@0: end tomwalters@0: if isfield(all_options,'movie') tomwalters@0: handles.info.calculate_movie=1; tomwalters@0: module_names=fieldnames(all_options.movie); % find out, which module name tomwalters@0: module_name=module_names{1}; % only the first one is relevant! tomwalters@0: handles.info.current_movie_module=module_name; % this one is the current one tomwalters@0: handles.all_options.movie=all_options.movie; % copy the parameters in place tomwalters@0: end tomwalters@0: tomwalters@0: handles=do_aim_calculate(handles); tomwalters@0: handles.error=0; tomwalters@0: tomwalters@0: result=handles; tomwalters@0: tomwalters@0: if isfield(all_options,'pcp') tomwalters@0: result.result=handles.data.pcp; tomwalters@0: end tomwalters@0: if isfield(all_options,'bmm') tomwalters@0: result.result=handles.data.bmm; tomwalters@0: end tomwalters@0: if isfield(all_options,'nap') tomwalters@0: result.result=handles.data.nap; tomwalters@0: end tomwalters@0: if isfield(all_options,'strobes') tomwalters@0: result.result=handles.data.strobes; tomwalters@0: end tomwalters@0: if isfield(all_options,'sai') tomwalters@0: result.result=handles.data.sai; tomwalters@0: end tomwalters@0: if isfield(all_options,'usermodule') tomwalters@0: result.result=handles.data.usermodule; tomwalters@0: end tomwalters@0: if isfield(all_options,'movie') tomwalters@0: end tomwalters@0: