Antw: Re: [FIELDTRIP] unclosed surfaces with BEM models

Gregor Volberg Gregor.Volberg at PSYCHOLOGIE.UNI-REGENSBURG.DE
Mon Aug 16 08:18:13 CEST 2010

Hi Paul,

thanks a lot for your reply! I will try OpenMEEG and I hope I can fix the
error soon. Meanwhile, I would be very glad if you could send me your modified
script for > 3 surfaces. This will surely help...
Thanks again, best regards,

Dr. rer. nat. Gregor Volberg <gregor.volberg at> (
mailto:gregor.volberg at )
University of Regensburg
Institute for Experimental Psychology
93040 Regensburg, Germany
Tel: +49 941 943 3862
Fax: +49 941 943 3233

>>> Paul Czienskowski <paul_c at GMX.DE> 8/13/2010 8:15 PM >>>
Hi Gregor,

I was trying to to run dipoli to  generate the  BEM-Models too but often
it failed with the very error. With some brains it worked checking
everything 'by hand' since the matlab routines to create the surfaces
seem to fail sometimes and produce an output that differs from the
volume very much (e.g. spikes on the surface). I was facing an error
lately when I obviously had some 'Inf' voxels in my volume for some
crude reason.
You may consider to switch to OpenMEEG because it's much better
documented than dipoli (which takes - indeed - no effort at all as
dipoli actually is not documented at all) and I think there are prebuilt
binaries for Debian on AMD64 infrastructure. If you're trying to run
OpenMEEG with more than 3 surfaces, which is supported by OpenMEEG but
not by fieldtrip, I may send you my modified scripts.

Hope this helps at least a bit.


Am 11.08.2010 15:52, schrieb Gregor Volberg:
> Dear fieldtrippers,
> I encounter a notorious error message about unclosed surfaces when computing
forward BEM models from individual MR anatomies. In oder to rule out that the
error arose during segmentation, I then used the example data from the tutorial
"Create BEM headmodel for EEG". Running the code with
> cfg = [];
> cfg.tissue         = [1 2 3];
> cfg.numvertices    = [1000 2000 3000]
> cfg.conductivity   = [1 1/80 1]
> cfg.sourceunits    = 'cm'
> cfg.mriunits       = 'mm'
> cfg.method         = 'dipoli';
> cfg.dipoli =
> vol = ft_prepare_bemmodel(cfg, mri); %where mri contains field .seg
> does the triangulation and computes the BEM model up to the following error
> (begin)
> ....
> Bmat countdown: 5010 (pass 2)
> Bmat countdown: 5000 (pass 2)
>   Fatal error in dipoli:  interface
/tmp/tp610e7212_00c2_4baa_a23e_3c28760eda25.tri is not a single closed surface
>   (totsolangle= -2.0000 from vertex 1 of
/tmp/tp7926a65d_2628_4e7d_9d88_44651dfa8674.tri )
> Warning: an error ocurred while running dipoli
>> In dipoli at 90
>    In ft_prepare_bemmodel at 112
> Error using ==>  fread
> Invalid file identifier.  Use fopen to generate a valid file identifier.
> Warning: File '/tmp/tpac730b26_4dd7_4599_814f_69b80a106b51.ama' not found.
>> In dipoli at 98
>    In ft_prepare_bemmodel at 112
> (end)
> I then tried the same code with the standard_vol distributed with fieldtrip,
and received the same error message, again after 1/6 of the second pass (2500
of 3000) was computed. Next I tried cfg.method = 'bemcp' instead of 'dipoli'
and got a warning message "Matrix is singular, close to singular or badly
scaled" and NaNs as output. According to recent postings in this group, this
error occurs if the three compartements intersect at one or more points.
> So, something in my code seems to tell fieldtrip that the surfaces are
intersecting or incomplete. Is there anything I am missing? Any hint would be
greatly appreciated. I use Matlab 7.8.0 (R2009a) on Debian Linux 64 bit and
just updated my fieldtrip version to 20100810.
> Best regards, Gregor

Paul Czienskowski
Björnsonstr. 25
12163 Berlin

Tel.: (+49)(0)30/221609359
Handy: (+49)(0)1788378772

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 and

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 and

More information about the fieldtrip mailing list