-
Notifications
You must be signed in to change notification settings - Fork 7
/
bem_generate_eeg_matrices.m
58 lines (51 loc) · 2.09 KB
/
bem_generate_eeg_matrices.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% bem_generate_eeg_matrices() - Generates BEM matrices for a BEM model.
%
% Usage:
% >> bem_generate_eeg_matrices(model);
%
% Inputs:
% model - model structure generated by BEM_CREATE_MODEL
%
% Notes: The matrices are created using the name given in the model structure
% The following matrices are created on disk, and can be read
% using the bem_load_model_matrix().
% <model.name>.cmt - BEM Coefficient matrix
% <model.name>.dmt - band of Coefficient matrix used by IPA
% <model.name>.imt - inner Coefficient Matrix used by IPA
%
% Author: Zeynep Akalin Acar, SCCN, 2007
% Copyright (C) 2007 Zeynep Akalin Acar, SCCN, [email protected]
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function bem_generate_eeg_matrices(model)
% load bem configuration for path names
conf = nft_get_config;
% check model and mesh fields
if ~isempty(find(isfield(model, {'name', 'mesh', 'mod'}) == 0,1))
error('BEM:bem_generate_eeg_matrices:model','%s','Invalid model');
end
mesh = model.mesh;
if ~isempty(find(isfield(mesh, {'name','num_class'}) == 0,1))
error('BEM:bem_generate_eeg_matrices:mesh','%s','Invalid mesh');
end
a = sprintf('"%s" -f "%s" -o %d "%s"', ...
conf.bem_matrix_program, model.name, model.mod, mesh.name);
for i = 1:mesh.num_class
a = sprintf('%s %d=%0.5g', a, i, model.cond(i));
end
[status, result] = system(a);
if status ~= 0
error('BEM:bem_generate_eeg_matrices:system','Failed to execute: %s',result);
end