External Email - Use Caution
Hi Vladimir,
This below should help you:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
create bem model for fsaverage
This is done only once
"""
import mne
root_dir = '/Your/data/path/'
subjects_dir = root_dir + 'subjects/'
mne.set_config('SUBJECTS_DIR',subjects_dir)
subject = 'fsaverage'
# This defines a source space (a mesh)
src = mne.setup_source_space(subject=subject,spacing='ico4')
mne.write_source_spaces(subjects_dir + subject +'/'+
subject+'-ico4-src.fif',src)
# Create and solve a BEM model takes a few lines
# following line crashes in my install but I was too lazy to file an issue.
lines below do the same calling shell scripts
#mne.bem.make_watershed_bem(subject=subject,overwrite=True)
from subprocess import call
code = call(['mne','watershed_bem','-s',subject,'--overwrite'])
if code:
raise ValueError('mne_watershed_bem failed')
# Make BEM
model = mne.bem.make_bem_model(subject = subject, conductivity=[0.3])
mne.bem.write_bem_surfaces(subjects_dir+ subject +'/' +
subject+'-5120-bem.fif', model)
# solve BEM
bem_sol = mne.bem.make_bem_solution(model)
mne.bem.write_bem_solution(subjects_dir+ subject +'/' +
subject+'-5120-bem-sol.fif',bem_sol)
# check that everything completed properly. Compare with online tutorial
https://www.martinos.org/mne/stable/auto_tutorials/plot_forward.html#sphx-glr-auto-tutorials-plot-forward-py
mne.viz.plot_bem(subject=subject, subjects_dir=subjects_dir,
brain_surfaces='white', orientation='coronal',
src = subjects_dir + subject +'/'+ subject+'-ico4-src.fif')
# the following lines will plot your BEM and source model together. (same
tutorial)
import numpy as np # noqa
from mayavi import mlab # noqa
from surfer import Brain # noqa
brain = Brain('sample', 'lh', 'inflated', subjects_dir=subjects_dir)
surf = brain.geo['lh']
vertidx = np.where(src[0]['inuse'])[0]
mlab.points3d(surf.x[vertidx], surf.y[vertidx],
surf.z[vertidx], color=(1, 1, 0), scale_factor=1.5)
Le mar. 18 sept. 2018 ? 20:56, Christian Markus Brodbeck <brodbeck at umd.edu>
a ?crit :
External Email - Use Caution
Hi Vladimir,
The subjects_dir is the directory which will contain your MRI subject
folders. It doe snot need to contain any MRIs yet.
Christian
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page
The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180919/f3bb2549/attachment.html