# issue with brainsuite and bem ico\_downsample

**URL:** <https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [April 4, 2019, 11:16pm UTC](https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807 "2019-04-04T23:16:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 4, 2019, 11:16pm UTC](https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807/1 "2019-04-04T23:16:09Z")

</div>

External Email - Use Caution

?Hi guys,  
I'm having some issues with the BEM meshes for my EEG data. I've tried two approaches:  
(1) Using freesurfer watershed and trying different preflood levels, but it seems to do a bad job with the outer\_skull.surf being misplaced (see attached image)  
(2) I've had better success with using Brainsuite and have followed the guidelines; converting it from dfs to surf using mne\_convert\_surface, and then reducing the number of triangles to 10,000 using mne\_reduce\_surface. When I try to run mne.make\_bem\_mode, I get the error:  
File "/usr/anaconda3/envs/mne/lib/python3.6/site-packages/mne/bem.py", line 344, in \_ico\_downsample

raise RuntimeError(bad\_msg)

RuntimeError: A surface with 10000 triangles cannot be isomorphic with a subdivided icosahedron.

Any ideas?

Best, Yvonne  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20190404/d09cdfbe/attachment-0001.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190404/d09cdfbe/attachment-0001.html)  
-------------- next part --------------  
A non-text attachment was scrubbed...  
Name: src\_surf\_bem.png  
Type: image/png  
Size: 201287 bytes  
Desc: src\_surf\_bem.png  
Url : [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20190404/d09cdfbe/attachment-0001.png](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190404/d09cdfbe/attachment-0001.png)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 5, 2019, 8:31am UTC](https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807/2 "2019-04-05T08:31:30Z")

</div>

External Email - Use Caution

hi Yvonne,

I've never tried this route to BEM model generation. Can you do this  
procedure with  
MNE sample dataset and share with us the generate .surf files so we can  
replicate  
and hopefully fix the pb?

ALex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 5, 2019, 1:54pm UTC](https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807/3 "2019-04-05T13:54:00Z")

</div>

External Email - Use Caution

The error is in the downsampling step (we should probably improve the  
message). Set `ico=None` and it won't try to downsample your surface:

[https://martinos.org/mne/stable/generated/mne.make\_bem\_model.html](https://martinos.org/mne/stable/generated/mne.make_bem_model.html)

It would be good indeed to see how this works with sample data and see if  
it affects source localization -- feel free to open an MNE issue about that.

Eric

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 6, 2019, 6:00pm UTC](https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807/4 "2019-04-06T18:00:41Z")

</div>

External Email - Use Caution

I opened an MNE issue for the downsampling problem ([https://github.com/mne-tools/mne-python/issues/6127](https://github.com/mne-tools/mne-python/issues/6127))

When I set the ico=None, I run into a new issue with mne.make\_bem\_solution after mne.make\_bem\_model. I don't get this issue with the MNE sample dataset but with my acquired T1's. Any ideas? Thanks for your help guys.

bem = mne.make\_bem\_solution(surfaces, verbose='INFO')

Approximation method : Linear collocation

Three-layer model surfaces loaded.

Computing the linear collocation solution...

Matrix coefficients...

head (5002) -\> head (5002) ...

/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/mne/bem.py:151: RuntimeWarning: divide by zero encountered in double\_scalars

miss /= (4.0 \* n\_memb)

head (5002) -\> outer\_skull (5002) ...

head (5002) -\> inner\_skull (5002) ...

outer\_skull (5002) -\> head (5002) ...

outer\_skull (5002) -\> outer\_skull (5002) ...

outer\_skull (5002) -\> inner\_skull (5002) ...

inner\_skull (5002) -\> head (5002) ...

inner\_skull (5002) -\> outer\_skull (5002) ...

inner\_skull (5002) -\> inner\_skull (5002) ...

Inverting the coefficient matrix...

Traceback (most recent call last):

File "\<ipython-input-18-24943e2f3a65\>", line 1, in \<module\>

bem = mne.make\_bem\_solution(surfaces, verbose='INFO')

File "\</dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/mne/externals/decorator.py:decorator-gen-39\>", line 2, in make\_bem\_solution

File "/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/mne/utils/\_logging.py", line 88, in wrapper

return function(\*args, \*\*kwargs)

File "/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/mne/bem.py", line 326, in make\_bem\_solution

\_fwd\_bem\_linear\_collocation\_solution(bem)

File "/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/mne/bem.py", line 267, in \_fwd\_bem\_linear\_collocation\_solution

m['solution'] = \_fwd\_bem\_multi\_solution(coeff, m['gamma'], nps)

File "/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/mne/bem.py", line 225, in \_fwd\_bem\_multi\_solution

return linalg.inv(solids, overwrite\_a=True)

File "/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/scipy/linalg/basic.py", line 945, in inv

a1 = \_asarray\_validated(a, check\_finite=check\_finite)

File "/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/scipy/\_lib/\_util.py", line 239, in \_asarray\_validated

a = toarray(a)

File "/dagher/dagher6/yyau/toolbox/anaconda3/envs/mne/lib/python3.6/site-packages/numpy/lib/function\_base.py", line 498, in asarray\_chkfinite

"array must not contain infs or NaNs")

ValueError: array must not contain infs or NaNs

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 6, 2019, 10:23pm UTC](https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807/5 "2019-04-06T22:23:50Z")

</div>

External Email - Use Caution

That divide by zero is probably the problem and might be fixable. Can you  
share the surfaces on DropBox or some other file hosting service?

Eric

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [April 6, 2019, 10:27pm UTC](https://mne.discourse.group/t/issue-with-brainsuite-and-bem-ico-downsample/1807/6 "2019-04-06T22:27:16Z")

</div>

External Email - Use Caution

Ahh I see that they are in the GitHub issue. I'll take a look next week if  
nobody beats me to it.

Eric
