本文整理汇总了Python中mne.report.Report.add_bem_to_section方法的典型用法代码示例。如果您正苦于以下问题:Python Report.add_bem_to_section方法的具体用法?Python Report.add_bem_to_section怎么用?Python Report.add_bem_to_section使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.report.Report
的用法示例。
在下文中一共展示了Report.add_bem_to_section方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_surfaces
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_bem_to_section [as 别名]
def copy_surfaces(sbj_id, mesh_files):
import os
import os.path as op
from smri_params import sbj_dir
from mne.report import Report
report = Report()
surf_names = ["brain_surface", "inner_skull_surface", "outer_skull_surface", "outer_skin_surface"]
new_surf_names = ["brain.surf", "inner_skull.surf", "outer_skull.surf", "outer_skin.surf"]
bem_dir = op.join(sbj_dir, sbj_id, "bem")
surface_dir = op.join(sbj_dir, sbj_id, "bem/watershed")
for i in range(len(surf_names)):
os.system(
"cp %s %s" % (op.join(surface_dir, sbj_id + "_" + surf_names[i]), op.join(bem_dir, new_surf_names[i]))
)
# op.join(bem_dir,sbj_id + '-' + new_surf_names[i])))
report.add_bem_to_section(subject=sbj_id, subjects_dir=sbj_dir)
report_filename = op.join(bem_dir, "BEM_report.html")
print "*** REPORT file %s written ***" % report_filename
print report_filename
report.save(report_filename, open_browser=False, overwrite=True)
return sbj_id
示例2: create_bem_sol
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_bem_to_section [as 别名]
def create_bem_sol(sbj_dir, sbj_id):
import os.path as op
import mne
from mne.bem import make_watershed_bem
from mne.report import Report
report = Report()
bem_dir = op.join(sbj_dir, sbj_id, 'bem')
surf_name = 'inner_skull.surf'
sbj_inner_skull_fname = op.join(bem_dir, sbj_id + '-' + surf_name)
inner_skull_fname = op.join(bem_dir, surf_name)
# check if bem-sol was created, if not creates the bem sol using C MNE
bem_fname = op.join(bem_dir, '%s-5120-bem-sol.fif' % sbj_id)
model_fname = op.join(bem_dir, '%s-5120-bem.fif' % sbj_id)
if not op.isfile(bem_fname):
# chek if inner_skull surf exists, if not BEM computation is
# performed by MNE python functions mne.bem.make_watershed_bem
if not (op.isfile(sbj_inner_skull_fname) or
op.isfile(inner_skull_fname)):
print inner_skull_fname + '---> FILE NOT FOUND!!!---> BEM computed'
make_watershed_bem(sbj_id, sbj_dir, overwrite=True)
else:
print '\n*** inner skull %s surface exists!!!\n' % inner_skull_fname
# Create a BEM model for a subject
surfaces = mne.make_bem_model(sbj_id, ico=4, conductivity=[0.3],
subjects_dir=sbj_dir)
# Write BEM surfaces to a fiff file
mne.write_bem_surfaces(model_fname, surfaces)
# Create a BEM solution using the linear collocation approach
bem = mne.make_bem_solution(surfaces)
mne.write_bem_solution(bem_fname, bem)
print '\n*** BEM solution file %s written ***\n' % bem_fname
# add BEM figures to a Report
report.add_bem_to_section(subject=sbj_id, subjects_dir=sbj_dir)
report_filename = op.join(bem_dir, "BEM_report.html")
print '\n*** REPORT file %s written ***\n' % report_filename
print report_filename
report.save(report_filename, open_browser=False, overwrite=True)
else:
bem = bem_fname
print '\n*** BEM solution file %s exists!!! ***\n' % bem_fname
return bem
示例3: test_render_mri
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_bem_to_section [as 别名]
def test_render_mri():
"""Test rendering MRI for mne report."""
tempdir = _TempDir()
trans_fname_new = op.join(tempdir, 'temp-trans.fif')
for a, b in [[trans_fname, trans_fname_new]]:
shutil.copyfile(a, b)
report = Report(info_fname=raw_fname,
subject='sample', subjects_dir=subjects_dir)
report.parse_folder(data_path=tempdir, mri_decim=30, pattern='*')
report.save(op.join(tempdir, 'report.html'), open_browser=False)
assert repr(report)
report.add_bem_to_section('sample', caption='extra', section='foo',
subjects_dir=subjects_dir, decim=30)
report.save(op.join(tempdir, 'report.html'), open_browser=False,
overwrite=True)
示例4: compute_LF_matrix
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_bem_to_section [as 别名]
def compute_LF_matrix(sbj_id, sbj_dir, raw_info, aseg, spacing, labels):
import os.path as op
import mne
from mne.bem import make_watershed_bem
from mne.report import Report
from nipype.utils.filemanip import split_filename as split_f
from neuropype_ephy.compute_fwd_problem import create_mixed_source_space
report = Report()
bem_dir = op.join(sbj_dir, sbj_id, 'bem')
surf_name = 'inner_skull.surf'
sbj_inner_skull_fname = op.join(bem_dir, sbj_id + '-' + surf_name)
inner_skull_fname = op.join(bem_dir, surf_name)
data_path, raw_fname, ext = split_f(raw_info['filename'])
if aseg:
fwd_filename = op.join(data_path, '%s-%s-aseg-fwd.fif'
% (raw_fname, spacing))
else:
fwd_filename = op.join(data_path, '%s-%s-fwd.fif'
% (raw_fname, spacing))
# check if we have just created the fwd matrix
if not op.isfile(fwd_filename):
# check if bem-sol was created, if not creates the bem sol using C MNE
bem_fname = op.join(bem_dir, '%s-5120-bem-sol.fif' % sbj_id)
model_fname = op.join(bem_dir, '%s-5120-bem.fif' % sbj_id)
if not op.isfile(bem_fname):
# chek if inner_skull surf exists, if not BEM computation is
# performed by MNE python functions mne.bem.make_watershed_bem
if not (op.isfile(sbj_inner_skull_fname) or
op.isfile(inner_skull_fname)):
print sbj_inner_skull_fname + '---> FILE NOT FOUND!!! ---> BEM is computed'
make_watershed_bem(sbj_id, sbj_dir, overwrite=True)
else:
print '*** inner skull surface exists!!!'
# Create a BEM model for a subject
surfaces = mne.make_bem_model(sbj_id, ico=4, conductivity=[0.3],
subjects_dir=sbj_dir)
# Write BEM surfaces to a fiff file
mne.write_bem_surfaces(model_fname, surfaces)
# Create a BEM solution using the linear collocation approach
bem = mne.make_bem_solution(surfaces)
mne.write_bem_solution(bem_fname, bem)
print '*** BEM solution file %s written ***' % bem_fname
# add BEM figures to a Report
report.add_bem_to_section(subject=sbj_id, subjects_dir=sbj_dir)
report_filename = op.join(bem_dir, "BEM_report.html")
print report_filename
report.save(report_filename, open_browser=False, overwrite=True)
else:
bem = bem_fname
print '*** BEM solution file %s exists!!!' % bem_fname
# check if source space exists, if not it creates using mne-python fun
# we have to create the cortical surface source space even when aseg is
# True
src_fname = op.join(bem_dir, '%s-%s-src.fif' % (sbj_id, spacing))
if not op.isfile(src_fname):
src = mne.setup_source_space(sbj_id, subjects_dir=sbj_dir,
fname=True,
spacing=spacing.replace('-', ''),
add_dist=False, overwrite=True,
n_jobs=2)
print '*** source space file %s written ***' % src_fname
else:
print '*** source space file %s exists!!!' % src_fname
src = mne.read_source_spaces(src_fname)
if aseg:
src = create_mixed_source_space(sbj_dir, sbj_id, spacing,
labels, src)
n = sum(src[i]['nuse'] for i in range(len(src)))
print('il src space contiene %d spaces e %d vertici' % (len(src), n))
# check if the co-registration file was created
# if not raise an runtime error
trans_fname = op.join(data_path, '%s-trans.fif' % raw_fname)
if not op.isfile(trans_fname):
raise RuntimeError('coregistration file %s NOT found!!!'
% trans_fname)
# if all is ok creates the fwd matrix
mne.make_forward_solution(raw_info, trans_fname, src, bem,
fwd_filename,
mindist=5.0, # ignore sources <= 0mm from inner skull
meg=True, eeg=False,
n_jobs=2,
overwrite=True)
#.........这里部分代码省略.........
示例5: gen_html_report
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_bem_to_section [as 别名]
#.........这里部分代码省略.........
title = ('%s<br>%s["%s"] (N=%d)'
% (section, analysis, name, this_evoked.nave))
figs = plot_snr_estimate(this_evoked, inv,
verbose=False)
figs.axes[0].set_ylim(auto=True)
captions = ('%s<br>%s["%s"] (N=%d)'
% (section, analysis, name,
this_evoked.nave))
report.add_figs_to_section(
figs, captions, section=section,
image_format='svg')
print('%5.1f sec' % ((time.time() - t0),))
#
# BEM
#
section = 'BEM'
if p.report_params.get('bem', True) and has_fwd:
caption = '%s<br>%s' % (section, struc)
bem, src, trans, _ = _get_bem_src_trans(
p, raw.info, subj, struc)
if not bem['is_sphere']:
subjects_dir = mne.utils.get_subjects_dir(
p.subjects_dir, raise_error=True)
mri_fname = op.join(subjects_dir, struc, 'mri', 'T1.mgz')
if not op.isfile(mri_fname):
warnings.warn(
'Could not find MRI:\n%s\nIf using surrogate '
'subjects, use '
'params.report_params["bem"] = False to avoid '
'this warning', stacklevel=2)
else:
t0 = time.time()
print((' %s ... ' % section).ljust(ljust), end='')
report.add_bem_to_section(struc, caption, section,
decim=10, n_jobs=1,
subjects_dir=subjects_dir)
print('%5.1f sec' % ((time.time() - t0),))
else:
print(' %s skipped (sphere)' % section)
else:
print(' %s skipped' % section)
#
# Whitening
#
section = 'Whitening'
if p.report_params.get('whitening', False):
t0 = time.time()
print((' %s ... ' % section).ljust(ljust), end='')
whitenings = p.report_params['whitening']
if not isinstance(whitenings, (list, tuple)):
whitenings = [whitenings]
for whitening in whitenings:
assert isinstance(whitening, dict)
analysis = whitening['analysis']
name = whitening['name']
cov_name = op.join(p.work_dir, subj, p.cov_dir,
safe_inserter(whitening['cov'], subj))
# Load the inverse
fname_evoked = op.join(inv_dir, '%s_%d%s_%s_%s-ave.fif'
% (analysis, p.lp_cut, p.inv_tag,
p.eq_tag, subj))
if not op.isfile(cov_name):
print(' Missing cov: %s'
% op.basename(cov_name), end='')