本文整理汇总了Python中mne.report.Report.add_htmls_to_section方法的典型用法代码示例。如果您正苦于以下问题:Python Report.add_htmls_to_section方法的具体用法?Python Report.add_htmls_to_section怎么用?Python Report.add_htmls_to_section使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.report.Report
的用法示例。
在下文中一共展示了Report.add_htmls_to_section方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_htmls_to_section
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_htmls_to_section [as 别名]
def test_add_htmls_to_section():
"""Test adding html str to mne report.
"""
report = Report(info_fname=raw_fname, subject="sample", subjects_dir=subjects_dir)
html = "<b>MNE-Python is AWESOME</b>"
caption, section = "html", "html_section"
report.add_htmls_to_section(html, caption, section)
idx = report._sectionlabels.index("report_" + section)
html_compare = report.html[idx]
assert_true(html in html_compare)
示例2: test_add_htmls_to_section
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_htmls_to_section [as 别名]
def test_add_htmls_to_section():
"""Test adding html str to mne report."""
report = Report(info_fname=raw_fname,
subject='sample', subjects_dir=subjects_dir)
html = '<b>MNE-Python is AWESOME</b>'
caption, section = 'html', 'html_section'
report.add_htmls_to_section(html, caption, section)
idx = report._sectionlabels.index('report_' + section)
html_compare = report.html[idx]
assert_true(html in html_compare)
assert_true(repr(report))
示例3: compute_ica
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_htmls_to_section [as 别名]
#.........这里部分代码省略.........
fig = ica.plot_scores(scores, exclude=ecg_inds, labels='ecg',
title='', show=show)
report.add_figs_to_section(fig, 'scores ({})'.format(subject),
section=comment + 'ECG',
scale=img_scale)
current_exclude = [e for e in ica.exclude] # issue #2608 MNE
fig = ica.plot_sources(raw, ecg_inds, exclude=ecg_inds,
title=title % ('components', 'ecg'), show=show)
report.add_figs_to_section(fig, 'sources ({})'.format(subject),
section=comment + 'ECG',
scale=img_scale)
ica.exclude = current_exclude
fig = ica.plot_components(ecg_inds, ch_type=topo_ch_type,
title='', colorbar=True, show=show)
report.add_figs_to_section(fig, title % ('sources', 'ecg'),
section=comment + 'ECG', scale=img_scale)
ica.exclude = current_exclude
ecg_inds = ecg_inds[:n_max_ecg]
ica.exclude += ecg_inds
fig = ica.plot_sources(ecg_evoked, exclude=ecg_inds, show=show)
report.add_figs_to_section(fig, 'evoked sources ({})'.format(subject),
section=comment + 'ECG',
scale=img_scale)
fig = ica.plot_overlay(ecg_evoked, exclude=ecg_inds, show=show)
report.add_figs_to_section(fig,
'rejection overlay ({})'.format(subject),
section=comment + 'ECG',
scale=img_scale)
# detect EOG by correlation
picks_eog = np.concatenate(
[picks_, pick_types(raw.info, meg=False, eeg=False, ecg=False,
eog=True)])
eog_epochs = create_eog_epochs(raw, tmin=eog_tmin, tmax=eog_tmax,
picks=picks_eog, reject=reject_)
artifact_stats['eog_n_events'] = len(eog_epochs.events)
artifact_stats['eog_n_used'] = artifact_stats['eog_n_events']
eog_ave = eog_epochs.average()
report.add_figs_to_section(eog_ave.plot(), 'EOG-used', 'artifacts')
_put_artifact_range(artifact_stats, eog_ave, kind='eog')
eog_inds = None
if len(eog_epochs.events) > 0:
eog_inds, scores = ica.find_bads_eog(eog_epochs)
if eog_inds is not None and len(eog_epochs.events) > 0:
fig = ica.plot_scores(scores, exclude=eog_inds, labels='eog',
show=show, title='')
report.add_figs_to_section(fig, 'scores ({})'.format(subject),
section=comment + 'EOG',
scale=img_scale)
current_exclude = [e for e in ica.exclude] # issue #2608 MNE
fig = ica.plot_sources(raw, eog_inds, exclude=ecg_inds,
title=title % ('sources', 'eog'), show=show)
report.add_figs_to_section(fig, 'sources', section=comment + 'EOG',
scale=img_scale)
ica.exclude = current_exclude
fig = ica.plot_components(eog_inds, ch_type=topo_ch_type,
title='', colorbar=True, show=show)
report.add_figs_to_section(fig, title % ('components', 'eog'),
section=comment + 'EOG', scale=img_scale)
ica.exclude = current_exclude
eog_inds = eog_inds[:n_max_eog]
ica.exclude += eog_inds
eog_evoked = eog_epochs.average()
fig = ica.plot_sources(eog_evoked, exclude=eog_inds, show=show)
report.add_figs_to_section(
fig, 'evoked sources ({})'.format(subject),
section=comment + 'EOG', scale=img_scale)
fig = ica.plot_overlay(eog_evoked, exclude=eog_inds, show=show)
report.add_figs_to_section(
fig, 'rejection overlay({})'.format(subject),
section=comment + 'EOG', scale=img_scale)
else:
del eog_epochs
# check the amplitudes do not change
if len(ica.exclude) > 0:
fig = ica.plot_overlay(raw, show=show) # EOG artifacts remain
html = _render_components_table(ica)
report.add_htmls_to_section(
html, captions='excluded components',
section='ICA rejection summary (%s)' % ch_type)
report.add_figs_to_section(
fig, 'rejection overlay({})'.format(subject),
section=comment + 'RAW', scale=img_scale)
return ica, dict(html=report, stats=artifact_stats)
示例4: generateReport
# 需要导入模块: from mne.report import Report [as 别名]
# 或者: from mne.report.Report import add_htmls_to_section [as 别名]
def generateReport(raw, ica, subj_name, subj_path, basename,
ecg_evoked, ecg_scores, ecg_inds, ECG_ch_name,
eog_evoked, eog_scores, eog_inds, EoG_ch_name):
from mne.report import Report
import numpy as np
import os
import HTML
report = Report()
ICA_title = 'Sources related to %s artifacts (red)'
is_show = False # visualization
File_length = str(round(raw.times[-1], 0))
# report.add_htmls_to_section(htmls=name_html, captions='File path', section='General')
name_html = '<h4 style="text-align:left;"> Path: ' + subj_path + '/' + basename + '.fif' + '</h4>'
ex_comps_table = [['', 'ICs to exclude'],['ECG', ecg_inds], ['EOG', eog_inds]]
ex_comps_html = '<h4>' + HTML.table(ex_comps_table) + '</h4>'
File_length_html = '<h4 style="text-align:left;">' + 'File length: ' + File_length + ' seconds' + '</h4>'
report.add_htmls_to_section(htmls=name_html + File_length_html + ex_comps_html, captions='General info', section='General info')
# --------------------- Generate report for ECG ---------------------------------------- #
fig1 = ica.plot_scores(
ecg_scores, exclude=ecg_inds, title=ICA_title % 'ecg', show=is_show)
# Pick the five largest ecg_scores and plot them
show_picks = np.abs(ecg_scores).argsort()[::-1][:5]
# Plot estimated latent sources given the unmixing matrix.
# topoplot of unmixing matrix columns
fig2 = ica.plot_components(
show_picks, title=ICA_title % 'ecg', colorbar=True, show=is_show)
# plot ECG sources + selection
fig3 = ica.plot_sources(ecg_evoked, exclude=ecg_inds, show=is_show)
fig = [fig1, fig2, fig3]
report.add_figs_to_section(fig, captions=['Scores of ICs related to ECG',
'TopoMap of ICs (ECG)',
'Time-locked ECG sources'], section='ICA - ECG')
# ----------------------------------- end generate report for ECG ------------------------------- #
# --------------------------------- Generate report for EoG --------------------------------------------- #
# check how many EoG ch we have
if set(EoG_ch_name.split(',')).issubset(set(raw.info['ch_names'])):
fig4 = ica.plot_scores(
eog_scores, exclude=eog_inds, title=ICA_title % 'eog', show=is_show)
report.add_figs_to_section(fig4, captions=['Scores of ICs related to EOG'],
section='ICA - EOG')
rs = np.shape(eog_scores)
if len(rs) > 1:
rr = rs[0]
show_picks = [np.abs(eog_scores[i][:]).argsort()[::-1][:5]
for i in range(rr)]
for i in range(rr):
fig5 = ica.plot_components(show_picks[i][:], title=ICA_title % 'eog',
colorbar=True, show=is_show) # ICA nel tempo
fig = [fig5]
report.add_figs_to_section(fig, captions=['Scores of ICs related to EOG'],
section='ICA - EOG')
else:
show_picks = np.abs(eog_scores).argsort()[::-1][:5]
fig5 = ica.plot_components(
show_picks, title=ICA_title % 'eog', colorbar=True, show=is_show)
fig = [fig5]
report.add_figs_to_section(fig, captions=['TopoMap of ICs (EOG)', ],
section='ICA - EOG')
fig9 = ica.plot_sources(eog_evoked, exclude=eog_inds, show=is_show) # plot EOG sources + selection
# fig10 = ica.plot_overlay(eog_evoked, exclude=eog_inds, show=is_show) # plot EOG cleaning
# fig = [fig9, fig10]
fig = [fig9]
report.add_figs_to_section(fig, captions=['Time-locked EOG sources'], section = 'ICA - EOG')
# -------------------- end generate report for EoG -------------------------------------------------------- #
# import ipdb; ipdb.set_trace()
IC_nums = range(ica.n_components_)
fig = ica.plot_components(picks=IC_nums, show=False)
report.add_figs_to_section(fig, captions=['All IC topographies'], section='ICA - muscles')
psds = []
captions_psd = []
ica_src = ica.get_sources(raw)
for iIC in IC_nums:
fig = ica_src.plot_psd(tmax=None, picks=[iIC], fmax=140, show=False)
fig.set_figheight(3)
fig.set_figwidth(5)
psds.append(fig)
captions_psd.append('IC #' + str(iIC))
# report.add_slider_to_section(figs=psds, captions=captions_psd, title='', section='ICA - muscles')
report.add_figs_to_section(figs=psds, captions=captions_psd, section='ICA - muscles')
report_filename = os.path.join(subj_path, basename + "-report.html")
print '******* ' + report_filename
report.save(report_filename, open_browser=False, overwrite=True)