comparison aim-mat/gui/loadallparameterfiles.m @ 0:74dedb26614d

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