tomwalters@0
|
1 % procedure for 'aim-mat'
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % INPUT VALUES:
|
tomwalters@0
|
4 %
|
tomwalters@0
|
5 % RETURN VALUE:
|
tomwalters@0
|
6 %
|
tomwalters@0
|
7 %
|
tomwalters@0
|
8 % (c) 2011, University of Southampton
|
bleeck@3
|
9 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
10 % download of current version is on the soundsoftware site:
|
bleeck@3
|
11 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
12 % documentation and everything is on http://www.acousticscale.org
|
bleeck@3
|
13
|
tomwalters@0
|
14
|
tomwalters@0
|
15
|
tomwalters@0
|
16 function handles=loadallparameterfiles(handles)
|
tomwalters@0
|
17 % go through all directories and call the single module-parameterfiles
|
tomwalters@0
|
18
|
tomwalters@0
|
19 % first find the directory, where all modules are saved. This directory
|
tomwalters@0
|
20 % should usually be next to the \aim\matlab - directory: \aim\
|
tomwalters@0
|
21 % find a module, that is always there:
|
tomwalters@0
|
22 fpa=which('gen_gtfb');
|
tomwalters@0
|
23 [a,b,c]=fileparts(fpa);
|
tomwalters@0
|
24 where=strfind(a,'modules');
|
tomwalters@0
|
25 if isempty(where)
|
tomwalters@0
|
26 str=sprintf('loadallparameterfiles: Cant locate the module path (file gen_gtfb not found)');
|
tomwalters@0
|
27 disp(str);
|
tomwalters@0
|
28 % TODO: a better solution for this.
|
tomwalters@0
|
29 er=errordlg(str,'File Error');
|
tomwalters@0
|
30 set(er,'WindowStyle','modal');
|
tomwalters@0
|
31 handles.error=1;
|
tomwalters@0
|
32 return
|
tomwalters@0
|
33 end
|
tomwalters@0
|
34 columnpath=fpa(1:where+7);
|
tomwalters@0
|
35 handles.info.columnpath=columnpath; % save it for later
|
tomwalters@0
|
36
|
tomwalters@0
|
37 % save these for later, all other are overwritten
|
tomwalters@0
|
38 addsig=0;
|
tomwalters@0
|
39 if isfield(handles,'all_options')
|
tomwalters@0
|
40 if isfield(handles.all_options,'signal')
|
tomwalters@0
|
41 addsig=1;
|
tomwalters@0
|
42 signaloptions=handles.all_options.signal;
|
tomwalters@0
|
43 end
|
tomwalters@0
|
44 end
|
tomwalters@0
|
45 % now go recurse through all directories in columnpath
|
tomwalters@0
|
46 allcols=dir(columnpath);
|
tomwalters@0
|
47 nr_files=size(allcols);
|
tomwalters@0
|
48 completepath=path;
|
tomwalters@0
|
49 olddir=pwd;
|
tomwalters@0
|
50 for i=3:nr_files
|
tomwalters@0
|
51 current_column_name=allcols(i).name;
|
tomwalters@0
|
52 if ~strcmpi(current_column_name(1),'.') % we dont want hidden files
|
tomwalters@0
|
53 current_column_path=[columnpath current_column_name];
|
tomwalters@0
|
54 allmodules=dir(current_column_path);
|
tomwalters@0
|
55 nr_modules=size(allmodules);
|
tomwalters@0
|
56 if ~strcmp(current_column_name,'signal')
|
tomwalters@0
|
57 % cd(current_module_path)
|
tomwalters@0
|
58 for j=3:nr_modules
|
tomwalters@0
|
59 current_module_name=lower(allmodules(j).name);
|
tomwalters@0
|
60 if ~strcmpi(current_module_name(1),'.')
|
tomwalters@0
|
61 current_module_path=fullfile(current_column_path,current_module_name);
|
tomwalters@0
|
62
|
tomwalters@0
|
63 % if the path is not in the matlab search path, add it
|
tomwalters@0
|
64 % to it and print a notice!
|
tomwalters@0
|
65 if isempty(strfind(completepath,current_module_path)) % the module is not in the path
|
tomwalters@0
|
66 addpath(current_module_path);
|
tomwalters@0
|
67 disp(sprintf('Directory %s was added to the path!',current_module_path));
|
tomwalters@0
|
68 end
|
tomwalters@0
|
69
|
tomwalters@0
|
70 cd(current_module_path)
|
tomwalters@0
|
71 try
|
tomwalters@0
|
72 eval('parameters'); % call the standart parameters. Then we have a struct
|
tomwalters@0
|
73 str=sprintf('all_options.%s.%s=%s;',current_column_name,current_module_name,current_module_name);
|
tomwalters@0
|
74 eval(str);
|
tomwalters@0
|
75 cstr=sprintf('allo=all_options.%s.%s;',current_column_name,current_module_name);
|
tomwalters@0
|
76 eval(cstr);
|
tomwalters@0
|
77 if isfield(allo,'displayfunction')==1
|
tomwalters@0
|
78 dstr=sprintf('all_options.%s.%s.displayfunction=''%s'';',current_column_name,current_module_name,allo.displayfunction);
|
tomwalters@0
|
79 eval(dstr);
|
tomwalters@0
|
80 else if strcmp(current_column_name,'usermodule') && ~strcmp(current_column_name,'graphics')
|
tomwalters@0
|
81 dstr=sprintf('all_options.%s.%s.displayfunction='''';',current_column_name,current_module_name);
|
tomwalters@0
|
82 eval(dstr);
|
tomwalters@0
|
83 end
|
tomwalters@0
|
84 end
|
tomwalters@0
|
85
|
tomwalters@0
|
86 eval(sprintf('clear %s',current_module_name));
|
tomwalters@0
|
87 catch
|
tomwalters@0
|
88 % either pop up a window
|
tomwalters@0
|
89 % str=sprintf('The parameter file for the module: %s produced errors!',current_module_path);
|
tomwalters@0
|
90 % er=errordlg(str,'File Error');
|
tomwalters@0
|
91 % set(er,'WindowStyle','modal');
|
tomwalters@0
|
92 % or just plot a warning message on the screen
|
tomwalters@0
|
93 str=sprintf('The parameter file for the module: %s produced errors!',current_module_path);
|
tomwalters@0
|
94 disp(str);
|
tomwalters@0
|
95
|
tomwalters@0
|
96 % stop program
|
tomwalters@0
|
97 % handles.error=1;
|
tomwalters@0
|
98 % cd(olddir);
|
tomwalters@0
|
99 % return
|
tomwalters@0
|
100 %
|
tomwalters@0
|
101 % or continue:
|
tomwalters@0
|
102 end
|
tomwalters@0
|
103 end
|
tomwalters@0
|
104 end
|
tomwalters@0
|
105 end
|
tomwalters@0
|
106 end
|
tomwalters@0
|
107 end
|
tomwalters@0
|
108 cd(olddir);
|
tomwalters@0
|
109 handles.all_options=all_options;
|
tomwalters@0
|
110 if addsig==1
|
tomwalters@0
|
111 handles.all_options.signal=signaloptions;
|
tomwalters@0
|
112 end
|
tomwalters@0
|
113
|
tomwalters@0
|
114
|
tomwalters@0
|
115 % save the new path
|
tomwalters@0
|
116 allpath=path;
|
tomwalters@0
|
117 path(allpath);
|