tomwalters@0
|
1 % procedure for 'aim-mat'
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % INPUT VALUES:
|
tomwalters@0
|
4 % paramfile : the name of a m-file with all relevant parameters for the project
|
tomwalters@0
|
5 % OR: the name of an struct with all relevant information
|
tomwalters@0
|
6 %
|
tomwalters@0
|
7 % RETURN VALUE:
|
tomwalters@0
|
8 % result : the output of the last stage in the parameter file
|
tomwalters@0
|
9 %
|
tomwalters@0
|
10 % aim_ng (aim no graphic) calculates aim up to the stage of that is indicated
|
tomwalters@0
|
11 % by the parameters in the file
|
tomwalters@0
|
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
|
bleeck@3
|
18
|
bleeck@3
|
19
|
tomwalters@0
|
20
|
tomwalters@0
|
21 function result=aim_ng(paramfile)
|
tomwalters@0
|
22
|
tomwalters@0
|
23 if isstruct(paramfile)
|
tomwalters@0
|
24 all_options=paramfile;
|
tomwalters@0
|
25 else
|
tomwalters@0
|
26 olddir=pwd;
|
tomwalters@0
|
27 [pathstr,name,ext] = fileparts(paramfile);
|
tomwalters@0
|
28 if ~isempty(pathstr)
|
tomwalters@0
|
29 cd(pathstr);
|
tomwalters@0
|
30 end
|
tomwalters@0
|
31 try
|
tomwalters@0
|
32 eval(name); % evaluate the parameter file. Afterwards we have a set of parameters (hopefully in all_options)
|
bleeck@3
|
33 cd(olddir);
|
tomwalters@0
|
34 catch
|
tomwalters@0
|
35 str=sprintf('The parameter file %s.m produced errors!',name);
|
tomwalters@0
|
36 er=errordlg(str,'File Error');
|
tomwalters@0
|
37 set(er,'WindowStyle','modal');
|
tomwalters@0
|
38 pause;
|
tomwalters@0
|
39 result=0;
|
tomwalters@0
|
40 cd olddir;
|
tomwalters@0
|
41 return
|
tomwalters@0
|
42 end
|
tomwalters@0
|
43 end
|
tomwalters@0
|
44
|
tomwalters@0
|
45 handles=[];
|
tomwalters@0
|
46 if isstruct(paramfile)
|
tomwalters@0
|
47 if isfield(paramfile,'graphics')
|
tomwalters@0
|
48 handles.all_options.graphics=paramfile.graphics;
|
tomwalters@0
|
49 end
|
tomwalters@0
|
50 end
|
tomwalters@0
|
51
|
tomwalters@0
|
52 % signalname:
|
tomwalters@0
|
53 signame=all_options.signal.signal_filename;
|
tomwalters@0
|
54
|
tomwalters@0
|
55 % set up all names, in case we need them:
|
tomwalters@0
|
56 handles=setupnames(handles,signame);
|
tomwalters@0
|
57
|
tomwalters@0
|
58 % no graphic please!
|
tomwalters@0
|
59 handles.with_graphic=0;
|
tomwalters@0
|
60
|
tomwalters@0
|
61 % in the no graphic version, do not store the results
|
tomwalters@0
|
62 handles.info.save_signal=0;
|
tomwalters@0
|
63 handles.info.save_pcp=0;
|
tomwalters@0
|
64 handles.info.save_bmm=0;
|
tomwalters@0
|
65 handles.info.save_nap=0;
|
tomwalters@0
|
66 handles.info.save_strobes=0;
|
tomwalters@0
|
67 handles.info.save_sai=0;
|
tomwalters@0
|
68 handles.info.save_usermodule=0;
|
tomwalters@0
|
69 handles.info.save_movie=0;
|
tomwalters@0
|
70 % default values
|
tomwalters@0
|
71 handles.info.calculate_signal=0;
|
tomwalters@0
|
72 handles.info.calculate_pcp=0;
|
tomwalters@0
|
73 handles.info.calculate_bmm=0;
|
tomwalters@0
|
74 handles.info.calculate_nap=0;
|
tomwalters@0
|
75 handles.info.calculate_strobes=0;
|
tomwalters@0
|
76 handles.info.calculate_sai=0;
|
tomwalters@0
|
77 handles.info.calculate_usermodule=0;
|
tomwalters@0
|
78 handles.info.calculate_movie=0;
|
tomwalters@0
|
79
|
tomwalters@0
|
80
|
tomwalters@0
|
81
|
tomwalters@0
|
82 % first load the signal, that must be there!
|
tomwalters@0
|
83 sigfile=all_options.signal.signal_filename;
|
tomwalters@0
|
84 % where=strfind(sigfile,'.wav');
|
tomwalters@0
|
85 % handles.info.uniqueworkingname=sigfile(1:where-1);
|
tomwalters@0
|
86
|
tomwalters@0
|
87 handles.all_options.signal=all_options.signal;
|
tomwalters@0
|
88 sig=loadwavefile(signal,sigfile);
|
tomwalters@0
|
89 handles.data.signal=sig;
|
tomwalters@0
|
90 handles.data.original_signal=sig;
|
tomwalters@0
|
91
|
tomwalters@0
|
92 % now find out, which column we want to calculate:
|
tomwalters@0
|
93 if isfield(all_options,'pcp')
|
tomwalters@0
|
94 handles.info.calculate_pcp=1;
|
tomwalters@0
|
95 module_names=fieldnames(all_options.pcp); % find out, which module name
|
tomwalters@0
|
96 module_name=module_names{1}; % only the first one is relevant!
|
tomwalters@0
|
97 handles.info.current_pcp_module=module_name; % this one is the current one
|
tomwalters@0
|
98 handles.all_options.pcp=all_options.pcp; % copy the parameters in place
|
tomwalters@0
|
99 end
|
tomwalters@0
|
100 if isfield(all_options,'bmm')
|
tomwalters@0
|
101 handles.info.calculate_bmm=1;
|
tomwalters@0
|
102 module_names=fieldnames(all_options.bmm); % find out, which module name
|
tomwalters@0
|
103 module_name=module_names{1}; % only the first one is relevant!
|
tomwalters@0
|
104 handles.info.current_bmm_module=module_name; % this one is the current one
|
tomwalters@0
|
105 handles.all_options.bmm=all_options.bmm; % copy the parameters in place
|
tomwalters@0
|
106 end
|
tomwalters@0
|
107 if isfield(all_options,'nap')
|
tomwalters@0
|
108 handles.info.calculate_nap=1;
|
tomwalters@0
|
109 module_names=fieldnames(all_options.nap); % find out, which module name
|
tomwalters@0
|
110 module_name=module_names{1}; % only the first one is relevant!
|
tomwalters@0
|
111 handles.info.current_nap_module=module_name; % this one is the current one
|
tomwalters@0
|
112 handles.all_options.nap=all_options.nap; % copy the parameters in place
|
tomwalters@0
|
113 end
|
tomwalters@0
|
114 if isfield(all_options,'strobes')
|
tomwalters@0
|
115 handles.info.calculate_strobes=1;
|
tomwalters@0
|
116 module_names=fieldnames(all_options.strobes); % find out, which module name
|
tomwalters@0
|
117 module_name=module_names{1}; % only the first one is relevant!
|
tomwalters@0
|
118 handles.info.current_strobes_module=module_name; % this one is the current one
|
tomwalters@0
|
119 handles.all_options.strobes=all_options.strobes; % copy the parameters in place
|
tomwalters@0
|
120 end
|
tomwalters@0
|
121 if isfield(all_options,'sai')
|
tomwalters@0
|
122 handles.info.calculate_sai=1;
|
tomwalters@0
|
123 module_names=fieldnames(all_options.sai); % find out, which module name
|
tomwalters@0
|
124 module_name=module_names{1}; % only the first one is relevant!
|
tomwalters@0
|
125 handles.info.current_sai_module=module_name; % this one is the current one
|
tomwalters@0
|
126 handles.all_options.sai=all_options.sai; % copy the parameters in place
|
tomwalters@0
|
127 end
|
tomwalters@0
|
128 if isfield(all_options,'usermodule')
|
tomwalters@0
|
129 handles.info.calculate_usermodule=1;
|
tomwalters@0
|
130 module_names=fieldnames(all_options.usermodule); % find out, which module name
|
tomwalters@0
|
131 module_name=module_names{1}; % only the first one is relevant!
|
tomwalters@0
|
132 handles.info.current_usermodule_module=module_name; % this one is the current one
|
tomwalters@0
|
133 handles.all_options.usermodule=all_options.usermodule; % copy the parameters in place
|
tomwalters@0
|
134 end
|
tomwalters@0
|
135 if isfield(all_options,'movie')
|
tomwalters@0
|
136 handles.info.calculate_movie=1;
|
tomwalters@0
|
137 module_names=fieldnames(all_options.movie); % find out, which module name
|
tomwalters@0
|
138 module_name=module_names{1}; % only the first one is relevant!
|
tomwalters@0
|
139 handles.info.current_movie_module=module_name; % this one is the current one
|
tomwalters@0
|
140 handles.all_options.movie=all_options.movie; % copy the parameters in place
|
tomwalters@0
|
141 end
|
tomwalters@0
|
142
|
tomwalters@0
|
143 handles=do_aim_calculate(handles);
|
tomwalters@0
|
144 handles.error=0;
|
tomwalters@0
|
145
|
tomwalters@0
|
146 result=handles;
|
tomwalters@0
|
147
|
tomwalters@0
|
148 if isfield(all_options,'pcp')
|
tomwalters@0
|
149 result.result=handles.data.pcp;
|
tomwalters@0
|
150 end
|
tomwalters@0
|
151 if isfield(all_options,'bmm')
|
tomwalters@0
|
152 result.result=handles.data.bmm;
|
tomwalters@0
|
153 end
|
tomwalters@0
|
154 if isfield(all_options,'nap')
|
tomwalters@0
|
155 result.result=handles.data.nap;
|
tomwalters@0
|
156 end
|
tomwalters@0
|
157 if isfield(all_options,'strobes')
|
tomwalters@0
|
158 result.result=handles.data.strobes;
|
tomwalters@0
|
159 end
|
tomwalters@0
|
160 if isfield(all_options,'sai')
|
tomwalters@0
|
161 result.result=handles.data.sai;
|
tomwalters@0
|
162 end
|
tomwalters@0
|
163 if isfield(all_options,'usermodule')
|
tomwalters@0
|
164 result.result=handles.data.usermodule;
|
tomwalters@0
|
165 end
|
tomwalters@0
|
166 if isfield(all_options,'movie')
|
tomwalters@0
|
167 end
|
tomwalters@0
|
168
|