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