tomwalters@0
|
1 % procedure for 'aim-mat'
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % function handles=aim_saveparameters(handles,filename,all_parameters)
|
tomwalters@0
|
4 %
|
tomwalters@0
|
5 % INPUT VALUES:
|
tomwalters@0
|
6 % handles: all relevant information
|
tomwalters@0
|
7 % filename: which file
|
tomwalters@0
|
8 % all_parameters: switch, whether all parameters shell be saved or only the relevant ones
|
tomwalters@0
|
9 % RETURN VALUE:
|
tomwalters@0
|
10 % handles: the updated handles
|
tomwalters@0
|
11 %
|
bleeck@3
|
12 %
|
tomwalters@0
|
13 % (c) 2011, University of Southampton
|
bleeck@3
|
14 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
15 % download of current version is on the soundsoftware site:
|
bleeck@3
|
16 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
17 % documentation and everything is on http://www.acousticscale.org
|
tomwalters@0
|
18
|
tomwalters@0
|
19
|
tomwalters@0
|
20 function handles=aim_saveparameters(handles,filename,all_parameters)
|
tomwalters@0
|
21
|
tomwalters@0
|
22 if nargin < 3
|
tomwalters@0
|
23 all_parameters=1; % save all parameters, not only the project relevant
|
tomwalters@0
|
24 end
|
tomwalters@0
|
25
|
tomwalters@0
|
26
|
tomwalters@0
|
27 id=fopen(filename,'wt');
|
tomwalters@0
|
28 lines=struct2stringarray(handles.all_options.bmm,'all_options.bmm');
|
tomwalters@0
|
29 fprintf(id,'\n%% Parameters');
|
tomwalters@0
|
30 fprintf(id,'\n%% for the project: \n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
31 fprintf(id,'\n%%');
|
tomwalters@0
|
32 filename=sprintf(' %s\n',handles.info.uniqueworkingname);
|
tomwalters@0
|
33 fprintf(id,filename);
|
tomwalters@0
|
34 fprintf(id,'%% %s',date);
|
tomwalters@0
|
35 fprintf(id,'\n%% produced by ');
|
tomwalters@0
|
36 result = license('inuse');
|
tomwalters@0
|
37 cuser=result(1).user;
|
tomwalters@0
|
38 fprintf(id,'%s',cuser);
|
tomwalters@0
|
39 fprintf(id,'\n');
|
tomwalters@0
|
40 fprintf(id,'\n\n%% Dont write anything in this file except for parameter values, \n%% since all other changes will be lost');
|
tomwalters@0
|
41 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
42 % fprintf(id,'\nclear all_options; %% clear the options initially to remove any old entries');
|
tomwalters@0
|
43 % fprintf(id,'\n');
|
tomwalters@0
|
44
|
tomwalters@0
|
45 if all_parameters==1 % save all parameters
|
tomwalters@0
|
46 lines=struct2stringarray(handles.all_options.signal,'all_options.signal');
|
tomwalters@0
|
47 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
48 fprintf(id,'\n%% Signaloptions\n');
|
tomwalters@0
|
49 for i=1:length(lines)
|
tomwalters@0
|
50 fprintf(id,lines{i});
|
tomwalters@0
|
51 fprintf(id,';\n');
|
tomwalters@0
|
52 end
|
tomwalters@0
|
53
|
tomwalters@0
|
54 lines=struct2stringarray(handles.all_options.pcp,'all_options.pcp');
|
tomwalters@0
|
55 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
56 fprintf(id,'\n%% outer/middle ear filter function\n');
|
tomwalters@0
|
57 for i=1:length(lines)
|
tomwalters@0
|
58 text=lines{i};
|
tomwalters@0
|
59 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
60 fprintf(id,text);
|
tomwalters@0
|
61 fprintf(id,';\n');
|
tomwalters@0
|
62 % end
|
tomwalters@0
|
63 end
|
tomwalters@0
|
64
|
tomwalters@0
|
65 lines=struct2stringarray(handles.all_options.bmm,'all_options.bmm');
|
tomwalters@0
|
66 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
67 fprintf(id,'\n%% bmm\n');
|
tomwalters@0
|
68 for i=1:length(lines)
|
tomwalters@0
|
69 text=lines{i};
|
tomwalters@0
|
70 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
71 fprintf(id,text);
|
tomwalters@0
|
72 fprintf(id,';\n');
|
tomwalters@0
|
73 % end
|
tomwalters@0
|
74 end
|
tomwalters@0
|
75 lines=struct2stringarray(handles.all_options.nap,'all_options.nap');
|
tomwalters@0
|
76 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
77 fprintf(id,'\n%% nap\n');
|
tomwalters@0
|
78 for i=1:length(lines)
|
tomwalters@0
|
79 text=lines{i};
|
tomwalters@0
|
80 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
81 fprintf(id,text);
|
tomwalters@0
|
82 fprintf(id,';\n');
|
tomwalters@0
|
83 % end
|
tomwalters@0
|
84 end
|
tomwalters@0
|
85 lines=struct2stringarray(handles.all_options.strobes,'all_options.strobes');
|
tomwalters@0
|
86 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
87 fprintf(id,'\n%% strobes\n');
|
tomwalters@0
|
88 for i=1:length(lines)
|
tomwalters@0
|
89 text=lines{i};
|
tomwalters@0
|
90 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
91 fprintf(id,text);
|
tomwalters@0
|
92 fprintf(id,';\n');
|
tomwalters@0
|
93 % end
|
tomwalters@0
|
94 end
|
tomwalters@0
|
95 lines=struct2stringarray(handles.all_options.sai,'all_options.sai');
|
tomwalters@0
|
96 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
97 fprintf(id,'\n%% sai\n');
|
tomwalters@0
|
98 for i=1:length(lines)
|
tomwalters@0
|
99 text=lines{i};
|
tomwalters@0
|
100 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
101 fprintf(id,text);
|
tomwalters@0
|
102 fprintf(id,';\n');
|
tomwalters@0
|
103 % end
|
tomwalters@0
|
104 end
|
tomwalters@0
|
105 lines=struct2stringarray(handles.all_options.usermodule,'all_options.usermodule');
|
tomwalters@0
|
106 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
107 fprintf(id,'\n%% user defined module\n');
|
tomwalters@0
|
108 for i=1:length(lines)
|
tomwalters@0
|
109 text=lines{i};
|
tomwalters@0
|
110 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
111 fprintf(id,text);
|
tomwalters@0
|
112 fprintf(id,';\n');
|
tomwalters@0
|
113 % end
|
tomwalters@0
|
114 end
|
tomwalters@0
|
115 lines=struct2stringarray(handles.all_options.movie,'all_options.movie');
|
tomwalters@0
|
116 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
117 fprintf(id,'\n%% movies\n');
|
tomwalters@0
|
118 for i=1:length(lines)
|
tomwalters@0
|
119 text=lines{i};
|
tomwalters@0
|
120 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
121 fprintf(id,text);
|
tomwalters@0
|
122 fprintf(id,';\n');
|
tomwalters@0
|
123 % end
|
tomwalters@0
|
124 end
|
tomwalters@0
|
125
|
tomwalters@0
|
126
|
tomwalters@0
|
127 else % save only the parameters, that are relevant for the current project
|
tomwalters@0
|
128
|
tomwalters@0
|
129 % if handles.info.signal_loaded==1
|
tomwalters@0
|
130 lines=struct2stringarray(handles.all_options.signal,'all_options.signal');
|
tomwalters@0
|
131 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
132 fprintf(id,'\n%% Signaloptions\n');
|
tomwalters@0
|
133 for i=1:length(lines)
|
tomwalters@0
|
134 text=lines{i};
|
tomwalters@0
|
135 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
136 fprintf(id,text);
|
tomwalters@0
|
137 fprintf(id,';\n');
|
tomwalters@0
|
138 % end
|
tomwalters@0
|
139 end
|
tomwalters@0
|
140 % end
|
tomwalters@0
|
141
|
tomwalters@0
|
142 if handles.info.pcp_loaded==1
|
tomwalters@0
|
143 lines=struct2stringarray(handles.all_options.pcp,'all_options.pcp');
|
tomwalters@0
|
144 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
145 fprintf(id,'\n%% outer/middle ear filter function\n');
|
tomwalters@0
|
146 module_name=['.pcp.' handles.info.current_pcp_module '.'];
|
tomwalters@0
|
147 for i=1:length(lines)
|
tomwalters@0
|
148 if ~isempty(strfind(lines{i},module_name))
|
tomwalters@0
|
149 text=lines{i};
|
tomwalters@0
|
150 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
151 fprintf(id,text);
|
tomwalters@0
|
152 fprintf(id,';\n');
|
tomwalters@0
|
153 % end
|
tomwalters@0
|
154 end
|
tomwalters@0
|
155 end
|
tomwalters@0
|
156 end
|
tomwalters@0
|
157
|
tomwalters@0
|
158 if handles.info.bmm_loaded==1
|
tomwalters@0
|
159 lines=struct2stringarray(handles.all_options.bmm,'all_options.bmm');
|
tomwalters@0
|
160 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
161 fprintf(id,'\n%% bmm\n');
|
tomwalters@0
|
162 module_name=['.bmm.' handles.info.current_bmm_module '.'];
|
tomwalters@0
|
163 for i=1:length(lines)
|
tomwalters@0
|
164 if ~isempty(strfind(lines{i},module_name))
|
tomwalters@0
|
165 text=lines{i};
|
tomwalters@0
|
166 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
167 fprintf(id,text);
|
tomwalters@0
|
168 fprintf(id,';\n');
|
tomwalters@0
|
169 % end
|
tomwalters@0
|
170 end
|
tomwalters@0
|
171 end
|
tomwalters@0
|
172 end
|
tomwalters@0
|
173
|
tomwalters@0
|
174 if handles.info.nap_loaded==1
|
tomwalters@0
|
175 lines=struct2stringarray(handles.all_options.nap,'all_options.nap');
|
tomwalters@0
|
176 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
177 fprintf(id,'\n%% nap\n');
|
tomwalters@0
|
178 module_name=['.nap.' handles.info.current_nap_module '.'];
|
tomwalters@0
|
179 for i=1:length(lines)
|
tomwalters@0
|
180 if ~isempty(strfind(lines{i},module_name))
|
tomwalters@0
|
181 text=lines{i};
|
tomwalters@0
|
182 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
183 fprintf(id,text);
|
tomwalters@0
|
184 fprintf(id,';\n');
|
tomwalters@0
|
185 % end
|
tomwalters@0
|
186 end
|
tomwalters@0
|
187 end
|
tomwalters@0
|
188 end
|
tomwalters@0
|
189
|
tomwalters@0
|
190 if handles.info.strobes_loaded==1
|
tomwalters@0
|
191 lines=struct2stringarray(handles.all_options.strobes,'all_options.strobes');
|
tomwalters@0
|
192 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
193 fprintf(id,'\n%% strobes\n');
|
tomwalters@0
|
194 module_name=['.strobes.' handles.info.current_strobes_module '.'];
|
tomwalters@0
|
195 for i=1:length(lines)
|
tomwalters@0
|
196 if ~isempty(strfind(lines{i},module_name))
|
tomwalters@0
|
197 text=lines{i};
|
tomwalters@0
|
198 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
199 fprintf(id,text);
|
tomwalters@0
|
200 fprintf(id,';\n');
|
tomwalters@0
|
201 % end
|
tomwalters@0
|
202 end
|
tomwalters@0
|
203 end
|
tomwalters@0
|
204 end
|
tomwalters@0
|
205
|
tomwalters@0
|
206 if handles.info.sai_loaded==1
|
tomwalters@0
|
207 lines=struct2stringarray(handles.all_options.sai,'all_options.sai');
|
tomwalters@0
|
208 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
209 fprintf(id,'\n%% sai\n');
|
tomwalters@0
|
210 module_name=['.sai.' handles.info.current_sai_module '.'];
|
tomwalters@0
|
211 for i=1:length(lines)
|
tomwalters@0
|
212 if ~isempty(strfind(lines{i},module_name))
|
tomwalters@0
|
213 text=lines{i};
|
tomwalters@0
|
214 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
215 fprintf(id,text);
|
tomwalters@0
|
216 fprintf(id,';\n');
|
tomwalters@0
|
217 % end
|
tomwalters@0
|
218 end
|
tomwalters@0
|
219 end
|
tomwalters@0
|
220 end
|
tomwalters@0
|
221
|
tomwalters@0
|
222
|
tomwalters@0
|
223 if handles.info.usermodule_loaded==1
|
tomwalters@0
|
224 lines=struct2stringarray(handles.all_options.usermodule,'all_options.usermodule');
|
tomwalters@0
|
225 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
226 fprintf(id,'\n%% user defined module\n');
|
tomwalters@0
|
227 module_name=['.usermodule.' handles.info.current_usermodule_module '.'];
|
tomwalters@0
|
228 for i=1:length(lines)
|
tomwalters@0
|
229 if ~isempty(strfind(lines{i},module_name))
|
tomwalters@0
|
230 text=lines{i};
|
tomwalters@0
|
231 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
232 fprintf(id,text);
|
tomwalters@0
|
233 fprintf(id,';\n');
|
tomwalters@0
|
234 % end
|
tomwalters@0
|
235 end
|
tomwalters@0
|
236 end
|
tomwalters@0
|
237 end
|
tomwalters@0
|
238
|
tomwalters@0
|
239 if handles.info.movie_loaded==1
|
tomwalters@0
|
240 lines=struct2stringarray(handles.all_options.movie,'all_options.movie');
|
tomwalters@0
|
241 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
242 fprintf(id,'\n%% movies\n');
|
tomwalters@0
|
243 module_name=['.movie.' handles.info.current_movie_module '.'];
|
tomwalters@0
|
244 for i=1:length(lines)
|
tomwalters@0
|
245 if ~isempty(strfind(lines{i},module_name))
|
tomwalters@0
|
246 text=lines{i};
|
tomwalters@0
|
247 % if isempty(strfind(text,'generatingfunction')) && isempty(strfind(text,'displayname')) && isempty(strfind(text,'displayfunction'))
|
tomwalters@0
|
248 fprintf(id,text);
|
tomwalters@0
|
249 fprintf(id,';\n');
|
tomwalters@0
|
250 % end
|
tomwalters@0
|
251 end
|
tomwalters@0
|
252 end
|
tomwalters@0
|
253 end
|
tomwalters@0
|
254
|
tomwalters@0
|
255
|
tomwalters@0
|
256 end
|
tomwalters@0
|
257
|
tomwalters@0
|
258 % and the graphic options. Important for the movies
|
tomwalters@0
|
259 lines=struct2stringarray(handles.all_options.graphics,'all_options.graphics');
|
tomwalters@0
|
260 fprintf(id,'\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%');
|
tomwalters@0
|
261 fprintf(id,'\n%% graphics\n');
|
tomwalters@0
|
262 for i=1:length(lines)
|
tomwalters@0
|
263 text=lines{i};
|
tomwalters@0
|
264 fprintf(id,text);
|
tomwalters@0
|
265 fprintf(id,';\n');
|
tomwalters@0
|
266 end
|
tomwalters@0
|
267
|
tomwalters@0
|
268 err=fclose(id);
|
tomwalters@0
|
269 if err~=0
|
tomwalters@0
|
270 ferror(id)
|
tomwalters@0
|
271 end
|
tomwalters@0
|
272 % pause(1)
|
tomwalters@0
|
273
|