tomwalters@0: % procedure for 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % 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: tomwalters@0: tomwalters@0: tomwalters@0: function handles=loadallparameterfiles(handles) tomwalters@0: % go through all directories and call the single module-parameterfiles tomwalters@0: tomwalters@0: % first find the directory, where all modules are saved. This directory tomwalters@0: % should usually be next to the \aim\matlab - directory: \aim\ tomwalters@0: % find a module, that is always there: tomwalters@0: fpa=which('gen_gtfb'); tomwalters@0: [a,b,c]=fileparts(fpa); tomwalters@0: where=strfind(a,'modules'); tomwalters@0: if isempty(where) tomwalters@0: str=sprintf('loadallparameterfiles: Cant locate the module path (file gen_gtfb not found)'); tomwalters@0: disp(str); tomwalters@0: % TODO: a better solution for this. tomwalters@0: er=errordlg(str,'File Error'); tomwalters@0: set(er,'WindowStyle','modal'); tomwalters@0: handles.error=1; tomwalters@0: return tomwalters@0: end tomwalters@0: columnpath=fpa(1:where+7); tomwalters@0: handles.info.columnpath=columnpath; % save it for later tomwalters@0: tomwalters@0: % save these for later, all other are overwritten tomwalters@0: addsig=0; tomwalters@0: if isfield(handles,'all_options') tomwalters@0: if isfield(handles.all_options,'signal') tomwalters@0: addsig=1; tomwalters@0: signaloptions=handles.all_options.signal; tomwalters@0: end tomwalters@0: end tomwalters@0: % now go recurse through all directories in columnpath tomwalters@0: allcols=dir(columnpath); tomwalters@0: nr_files=size(allcols); tomwalters@0: completepath=path; tomwalters@0: olddir=pwd; tomwalters@0: for i=3:nr_files tomwalters@0: current_column_name=allcols(i).name; tomwalters@0: if ~strcmpi(current_column_name(1),'.') % we dont want hidden files tomwalters@0: current_column_path=[columnpath current_column_name]; tomwalters@0: allmodules=dir(current_column_path); tomwalters@0: nr_modules=size(allmodules); tomwalters@0: if ~strcmp(current_column_name,'signal') tomwalters@0: % cd(current_module_path) tomwalters@0: for j=3:nr_modules tomwalters@0: current_module_name=lower(allmodules(j).name); tomwalters@0: if ~strcmpi(current_module_name(1),'.') tomwalters@0: current_module_path=fullfile(current_column_path,current_module_name); tomwalters@0: tomwalters@0: % if the path is not in the matlab search path, add it tomwalters@0: % to it and print a notice! tomwalters@0: if isempty(strfind(completepath,current_module_path)) % the module is not in the path tomwalters@0: addpath(current_module_path); tomwalters@0: disp(sprintf('Directory %s was added to the path!',current_module_path)); tomwalters@0: end tomwalters@0: tomwalters@0: cd(current_module_path) tomwalters@0: try tomwalters@0: eval('parameters'); % call the standart parameters. Then we have a struct tomwalters@0: str=sprintf('all_options.%s.%s=%s;',current_column_name,current_module_name,current_module_name); tomwalters@0: eval(str); tomwalters@0: cstr=sprintf('allo=all_options.%s.%s;',current_column_name,current_module_name); tomwalters@0: eval(cstr); tomwalters@0: if isfield(allo,'displayfunction')==1 tomwalters@0: dstr=sprintf('all_options.%s.%s.displayfunction=''%s'';',current_column_name,current_module_name,allo.displayfunction); tomwalters@0: eval(dstr); tomwalters@0: else if strcmp(current_column_name,'usermodule') && ~strcmp(current_column_name,'graphics') tomwalters@0: dstr=sprintf('all_options.%s.%s.displayfunction='''';',current_column_name,current_module_name); tomwalters@0: eval(dstr); tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: eval(sprintf('clear %s',current_module_name)); tomwalters@0: catch tomwalters@0: % either pop up a window tomwalters@0: % str=sprintf('The parameter file for the module: %s produced errors!',current_module_path); tomwalters@0: % er=errordlg(str,'File Error'); tomwalters@0: % set(er,'WindowStyle','modal'); tomwalters@0: % or just plot a warning message on the screen tomwalters@0: str=sprintf('The parameter file for the module: %s produced errors!',current_module_path); tomwalters@0: disp(str); tomwalters@0: tomwalters@0: % stop program tomwalters@0: % handles.error=1; tomwalters@0: % cd(olddir); tomwalters@0: % return tomwalters@0: % tomwalters@0: % or continue: tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: cd(olddir); tomwalters@0: handles.all_options=all_options; tomwalters@0: if addsig==1 tomwalters@0: handles.all_options.signal=signaloptions; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: % save the new path tomwalters@0: allpath=path; tomwalters@0: path(allpath);