function prepare_bemmodel: resulting BEM system matrix is NaN

Gwenael Birot gbirot at GMAIL.COM
Fri Feb 12 14:54:29 CET 2010


Hello,

I am a new user of fieldtrip. I am trying to generate BEM system matrix
using the function 'prepare_bemmodel' and the 'bemcp' method. The system
matrix 'vol.mat' I obtained using the following code is a 'NaN' matrix.

%% -------------- Begin --------------
% ---- load brain mesh
% load_bnd is a function to load brainvisa mesh
[vol.bnd(1).pnt vol.bnd(1).tri] = load_bnd('../data/mesh/colin_
no_artef.eeg-3.bnd');
vol.bnd(1).tri = vol.bnd(1).tri + 1;
vol.bnd(1).pnt = vol.bnd(1).pnt;

% ---- load skull mesh
[vol.bnd(2).pnt vol.bnd(2).tri] =
load_bnd('../data/mesh/colin_no_artef.eeg-2.bnd');
vol.bnd(2).tri = vol.bnd(2).tri + 1;
vol.bnd(2).pnt = vol.bnd(2).pnt/1000;

% ---- load skin mesh
[vol.bnd(3).pnt vol.bnd(3).tri] =
load_bnd('../data/mesh/colin_no_artef.eeg-1.bnd');
vol.bnd(3).tri = vol.bnd(3).tri + 1;
vol.bnd(3).pnt = vol.bnd(3).pnt;

% ---- check meshes
figure; triplot(vol.bnd(1).pnt, vol.bnd(1).tri, [], 'faces_skin'); rotate3d
figure; triplot(vol.bnd(2).pnt, vol.bnd(2).tri, [], 'faces_skin'); rotate3d
figure; triplot(vol.bnd(3).pnt, vol.bnd(3).tri, [], 'faces_skin'); rotate3d
% this gives good results, so meshes are correctly loaded

% ---- prepare BEM model
vol.cond   = [0.3300 0.0825 0.3300]; % conductivities
vol.skin   = 3; % index of skin surface
cfg = [];
cfg.method = 'bemcp';
vol = prepare_bemmodel(cfg, vol);
%% ------------------- End ------------------------

When executing this code I've got the following result in the matlab prompt

using the mesh specified in the input volume conductor
determining source compartment (1)
determining skin compartment (3)
not using the isolated source approach
Nvert = 1222
Ntri = 2440
weight = 0.095493 , defl =  0.000000
Nverta = 1222
Ntrib = 2440

Nverta = 1222
Ntrib = 2440
Nvert = 1222
Ntri = 2440
weight = -0.095493 , defl =  0.000000
Nverta = 1222
Ntrib = 2440
Warning: Matrix is singular, close to singular or badly scaled.
         Results may be inaccurate. RCOND = NaN.
> In prepare_bemmodel at 187
  In test_fieldtrip at 166
Nverta = 1222
Ntrib = 2440
Warning: Matrix is singular, close to singular or badly scaled.
         Results may be inaccurate. RCOND = NaN.
> In prepare_bemmodel at 194
  In test_fieldtrip at 166
Nverta = 1222
Ntrib = 2440
Nverta = 1222
Ntrib = 2440
Nvert = 1222
Ntri = 2440
weight = 0.159155 , defl =  0.000818
Warning: Matrix is singular, close to singular or badly scaled.
         Results may be inaccurate. RCOND = NaN.
> In prepare_bemmodel at 220
  In test_fieldtrip at 166

and as I mentionned the resulting BEM system matrix vol.mat is a 'NaN'
matrix. I guess the problem occurs in this part of the prepare_bemmodel
function (beginning at line 152):

  % --------------------------------------------
  % Deal first with surface 1 and 2 (inner and outer skull

  % NOTE:
  % C11st/C22st/C33st are simply the matrix C11/C22/C33 minus the identity
  % matrix, i.e. C11st = C11-eye(N)

  weight = (vol.cond(1)-vol.cond(2))/((vol.cond(1)+vol.cond(2))*2*pi);
  C11st  = bem_Cii_lin(vol.bnd(1).tri,vol.bnd(1).pnt,
weight,defl(1),vol.bnd(1).pnt4);
  weight = (vol.cond(1)-vol.cond(2))/((vol.cond(2)+vol.cond(3))*2*pi);
  C21    = bem_Cij_lin(vol.bnd(2).pnt,vol.bnd(1).pnt,vol.bnd(1).tri,
weight,defl(1));
  tmp1   = C21/C11st;

  weight = (vol.cond(2)-vol.cond(3))/((vol.cond(1)+vol.cond(2))*2*pi);
  C12    = bem_Cij_lin(vol.bnd(1).pnt,vol.bnd(2).pnt,vol.bnd(2).tri,
weight,defl(2));
  weight = (vol.cond(2)-vol.cond(3))/((vol.cond(2)+vol.cond(3))*2*pi);
  C22st  = bem_Cii_lin(vol.bnd(2).tri,vol.bnd(2).pnt,
weight,defl(2),vol.bnd(2).pnt4);
  tmp2   = C12/C22st;
  % ------------------------------------------------

where the matrix C11st contains three elements equal to NaN. Since C11st is
then inverted, the result is a 'NaN' matrix.

I'll would very much appreciate your help
Thanks
Gwenael

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20100212/d818d641/attachment-0001.html>


More information about the fieldtrip mailing list