def make_report(subject, subjects_dir, meg_filename, output_dir): #Create report from output report = Report(image_format='png', subjects_dir=subjects_dir, subject=subject, raw_psd=False) # use False for speed here #info_fname=meg_filename, report.parse_folder(output_dir, on_error='ignore', mri_decim=10) report_filename = op.join(output_dir, 'QA_report.html') report.save(report_filename)
def generate_report(subj): report = Report(subject=subj.name, title=subj.name) if subj.name == "sub-emptyroom": report.parse_folder(str(subj), render_bem=False) else: report.parse_folder(str(subj / "meg"), render_bem=False) # process head positions if subj.name != "sub-emptyroom": report = add_head_postions(subj, report) # add bad channels report = add_bad_channels(subj, report) # add maxwell filtering part report = add_maxwell_filtering_figures(subj, report) # -------- save results -------- # dest_dir = dirs.reports / subj.name dest_dir.mkdir(exist_ok=True) savename = dest_dir / (subj.name + "-report.html") report.save(str(savename), open_browser=False, overwrite=True)
def make_report(subject_id): subject = "sub%03d" % subject_id print("processing %s" % subject) meg_path = op.join(meg_dir, subject) ave_fname = op.join(meg_path, "%s-ave.fif" % subject) rep = Report(info_fname=ave_fname, subject=subject, subjects_dir=subjects_dir) rep.parse_folder(meg_path) evokeds = mne.read_evokeds(op.join(meg_path, '%s-ave.fif' % subject)) fam = evokeds[0] scramb = evokeds[1] unfam = evokeds[2] figs = list() captions = list() fig = fam.plot(spatial_colors=True, show=False, gfp=True) figs.append(fig) captions.append('Famous faces') fig = unfam.plot(spatial_colors=True, show=False, gfp=True) figs.append(fig) captions.append('Unfamiliar faces') fig = scramb.plot(spatial_colors=True, show=False, gfp=True) figs.append(fig) captions.append('Scrambled faces') if 'EEG070' in fam.ch_names: idx = fam.ch_names.index('EEG070') fig = mne.viz.plot_compare_evokeds({'Famous': fam, 'Unfamiliar': unfam, 'Scrambled': scramb}, idx, show=False) figs.append(fig) captions.append('Famous, unfamliliar and scrambled faces on EEG070') fname_trans = op.join(study_path, 'ds117', subject, 'MEG', '%s-trans.fif' % subject) mne.viz.plot_trans(fam.info, fname_trans, subject=subject, subjects_dir=subjects_dir, meg_sensors=True, eeg_sensors=True) fig = mlab.gcf() figs.append(fig) captions.append('Coregistration') rep.add_figs_to_section(figs, captions) for cond in ['faces', 'famous', 'unfamiliar', 'scrambled', 'contrast']: fname = op.join(meg_path, 'mne_dSPM_inverse-%s' % cond) stc = mne.read_source_estimate(fname, subject) brain = stc.plot(views=['ven'], hemi='both') brain.set_data_time_index(112) fig = mlab.gcf() rep._add_figs_to_section(fig, cond) rep.save(fname=op.join(meg_dir, 'report%s.html' % subject), open_browser=False, overwrite=True)
def make_report(subject_id): subject = "sub%03d" % subject_id print("processing %s" % subject) meg_path = op.join(meg_dir, subject) ave_fname = op.join(meg_path, "%s_highpass-%sHz-ave.fif" % (subject, l_freq)) rep = Report(info_fname=ave_fname, subject=subject, subjects_dir=subjects_dir) rep.parse_folder(meg_path) evokeds = mne.read_evokeds(ave_fname) fam = evokeds[0] scramb = evokeds[1] unfam = evokeds[2] figs = list() captions = list() fig = fam.plot(spatial_colors=True, show=False, gfp=True) figs.append(fig) captions.append('Famous faces') fig = unfam.plot(spatial_colors=True, show=False, gfp=True) figs.append(fig) captions.append('Unfamiliar faces') fig = scramb.plot(spatial_colors=True, show=False, gfp=True) figs.append(fig) captions.append('Scrambled faces') if 'EEG070' in fam.ch_names: idx = fam.ch_names.index('EEG070') fig = mne.viz.plot_compare_evokeds( { 'Famous': fam, 'Unfamiliar': unfam, 'Scrambled': scramb }, idx, show=False) figs.append(fig) captions.append('Famous, unfamliliar and scrambled faces on EEG070') fname_trans = op.join(study_path, 'ds117', subject, 'MEG', '%s-trans.fif' % subject) mne.viz.plot_trans(fam.info, fname_trans, subject=subject, subjects_dir=subjects_dir, meg_sensors=True, eeg_sensors=True) fig = mlab.gcf() figs.append(fig) captions.append('Coregistration') rep.add_figs_to_section(figs, captions) for cond in ['faces', 'famous', 'unfamiliar', 'scrambled', 'contrast']: fname = op.join(meg_path, 'mne_dSPM_inverse_highpass-%sHz-%s' % (l_freq, cond)) stc = mne.read_source_estimate(fname, subject) brain = stc.plot(views=['ven'], hemi='both') brain.set_data_time_index(112) fig = mlab.gcf() rep._add_figs_to_section(fig, cond) rep.save(fname=op.join(meg_dir, 'report%s.html' % subject), open_browser=False, overwrite=True)