[FieldTrip] head model mat contains only NaN values

Homölle, S. (Simon) S.Homolle at donders.ru.nl
Thu May 19 19:42:50 CEST 2016

Dear Gina,

 I see that the "scalp" has vertices that connect planes
internal to the brain (see images attached).

I guess this is the reason why you get the NaN values. BEM needs nested and sufficiently distant surfaces.

As I don't know the quality and sequence (T1, T2?) of your MRI I suggest you to look at the segmentation to be sure that this is well done. With a good segmentation preparing the mesh is not a problem.


Simon Homölle
PhD Candidate
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognitive Neuroimaging
Radboud University Nijmegen
Phone: +31-(0)24-36-65059

From: fieldtrip-bounces at science.ru.nl [fieldtrip-bounces at science.ru.nl] on behalf of gj [gina.joue at univr.it]
Sent: Thursday, May 19, 2016 6:36 PM
To: FieldTrip discussion list
Subject: [FieldTrip] head model mat contains only NaN values

Hi FieldTrippers,

While trying to calculate a head model (FT ver.20160309), the head model
contains only NaNs, and I get the following errors:

------------- beg error ------------
Warning: NaN detected, trying once more with slightly different vertex
 > In ft_prepare_headmodel (line 280)
Warning: No conductivity is declared, assuming standard values
 > In ft_headmodel_bemcp (line 79)
In ft_prepare_headmodel (line 281)

Warning: Matrix is singular, close to singular or badly scaled. Results
may be inaccurate. RCOND = NaN.
 > In ft_headmodel_bemcp (line 185)
   In ft_prepare_headmodel (line 281)
------------- end error ------------

This was what I ran:

smri = ft_read_mri(smrifn); % subject's own structural MRI

cfg = [];
mri.coordsys = 'MNI';
cfg.brainthreshold = 0.5;
cfg.output = {'brain','skull','scalp'};
smri_seg = ft_volumesegment(cfg, smri);

cfg.method = 'projectmesh';
cfg.numvertices = [2400 1600 800];

cfg = [];
cfg.method = 'bemcp';
headmodel = ft_prepare_headmodel(cfg, mesh_hd);

Not sure if this might be related, but we have head+neck MRIs and when I
plot the meshes, I see that the "scalp" has vertices that connect planes
internal to the brain (see images attached). I've tried different
ft_prepare_mesh methods, different number of vertices....

Thanks in advance for any advice!

More information about the fieldtrip mailing list