osl_ephys.report.preproc_report#

Reporting tool for preprocessing.

Functions#

gen_report_from_fif(infiles, outdir[, ftype, logsdir, ...])

Generate web-report for a set of MNE data objects.

get_header_id(raw)

Extract scan name from MNE data object.

gen_html_data(raw, outdir[, ica, events, event_id, ...])

Generate HTML web-report for an MNE data object.

gen_html_page(outdir[, logsdir, custom_figures])

Generate an HTML page from a report directory.

gen_html_summary(reportdir[, logsdir, custom_figures])

Generate an HTML summary from a report directory.

gen_summary_data(subject_data)

load_template(tname)

Load an HTML template from the templates directory.

plot_flowchart(raw[, savebase])

Plots preprocessing flowchart(s)

plot_rawdata(raw, savebase)

Plots raw data.

plot_channel_time_series(raw[, savebase, exclude_bads])

Plots sum-square time courses.

plot_sensors(raw[, savebase])

Plots sensors with bad channels highlighted.

plot_channel_dists(raw[, savebase, exclude_bads])

Plot distributions of temporal standard deviation.

plot_spectra(raw[, savebase])

Plot power spectra for each sensor modality.

plot_freqbands(raw[, savebase])

Plot power spectra for each sensor modality.

plot_digitisation_2d(raw[, savebase])

Plots the digitisation and headshape.

plot_headmovement(raw[, savebase])

Plot headmovement - WORK IN PROGRESS... seems v-slow atm

plot_eog_summary(raw[, savebase])

Plot raw EOG time series.

plot_ecg_summary(raw[, savebase])

Plot ECG summary.

plot_bad_ica(raw, ica, savebase)

Plot ICA characteristics for rejected components.

plot_summary_bad_segs(subject_data, reportdir)

Plot summary of bad channels over subjects.

plot_summary_bad_chans(subject_data, reportdir)

Plot summary of bad channels over subjects.

plot_artefact_scan(raw[, savebase])

Plot artefact scan.

print_scan_summary(raw)

Print a text summary of an MNE file.

plot_events(events, event_id, savebase)

plot_custom_figures(custom_figures, savebase)

Module Contents#

osl_ephys.report.preproc_report.gen_report_from_fif(infiles, outdir, ftype=None, logsdir=None, run_id=None)[source]#

Generate web-report for a set of MNE data objects.

Parameters:
  • infiles (list of str) – List of paths to fif files.

  • outdir (str) – Directory to save HTML report and figures to.

  • ftype (str) – Type of fif file, e.g., 'raw' or 'preproc-raw'.

  • logsdir (str) – Directory the log files were saved into. If None, log files are assumed to be in outdir.replace(‘report’, ‘logs’)

  • run_id (str) – Run ID.

osl_ephys.report.preproc_report.get_header_id(raw)[source]#

Extract scan name from MNE data object.

Parameters:

raw (mne.io.:py:class:mne.io.Raw <mne.io.Raw>.) – MNE Raw object.

Returns:

id – Scan name.

Return type:

str

osl_ephys.report.preproc_report.gen_html_data(raw, outdir, ica=None, events=None, event_id=None, preproc_fif_filename=None, logsdir=None, run_id=None, custom_figures=None)[source]#

Generate HTML web-report for an MNE data object.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • outdir (string) – Directory to write HTML data and plots to.

  • ica (mne.preprocessing.ICA) – ICA object.

  • events (array, shape (n_events, 3)) – The events.

  • event_id (dict) – The event IDs.

  • preproc_fif_filename (str) – Filename of file output by preprocessing

  • logsdir (str) – Directory the log files were saved into. If None, log files are assumed to be in reportdir.replace(‘report’, ‘logs’)

  • run_id (str) – Run ID.

  • custom_figures (dict) – Dictionary of custom figures to include in the report. Keys should be the figure names, and values should be the matplotlib figure objects.

osl_ephys.report.preproc_report.gen_html_page(outdir, logsdir=None, custom_figures=None)[source]#

Generate an HTML page from a report directory.

Parameters:

outdir (str) – Directory to generate HTML report with.

Returns:

success – Whether the report was successfully generated.

Return type:

bool

osl_ephys.report.preproc_report.gen_html_summary(reportdir, logsdir=None, custom_figures=None)[source]#

Generate an HTML summary from a report directory.

Parameters:
  • reportdir (str) – Directory to generate HTML summary report with.

  • logsdir (str) – Directory the log files were saved into. If None, log files are assumed to be in reportdir.replace(‘report’, ‘logs’)

osl_ephys.report.preproc_report.gen_summary_data(subject_data)[source]#
osl_ephys.report.preproc_report.load_template(tname)[source]#

Load an HTML template from the templates directory.

Parameters:

tname (str) – Name of the template to load.

Returns:

template – The loaded template.

Return type:

jinja2.Template

osl_ephys.report.preproc_report.plot_flowchart(raw, savebase=None)[source]#

Plots preprocessing flowchart(s)

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_rawdata(raw, savebase)[source]#

Plots raw data.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_channel_time_series(raw, savebase=None, exclude_bads=False)[source]#

Plots sum-square time courses.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

  • exclude_bads (bool) – Whether to exclude bad channels and bad segments.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_sensors(raw, savebase=None)[source]#

Plots sensors with bad channels highlighted.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_channel_dists(raw, savebase=None, exclude_bads=True)[source]#

Plot distributions of temporal standard deviation.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

  • exclude_bads (bool) – Whether to exclude bad channels and bad segments.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_spectra(raw, savebase=None)[source]#

Plot power spectra for each sensor modality.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

  • fpath1 (str) – Path to saved figure (full spectra).

  • fpath2 (str) – Path to saved figure (zoomed in spectra).

osl_ephys.report.preproc_report.plot_freqbands(raw, savebase=None)[source]#

Plot power spectra for each sensor modality.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

figname – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_digitisation_2d(raw, savebase=None)[source]#

Plots the digitisation and headshape.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_headmovement(raw, savebase=None)[source]#

Plot headmovement - WORK IN PROGRESS… seems v-slow atm

osl_ephys.report.preproc_report.plot_eog_summary(raw, savebase=None)[source]#

Plot raw EOG time series.

osl_ephys.report.preproc_report.plot_ecg_summary(raw, savebase=None)[source]#

Plot ECG summary.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_bad_ica(raw, ica, savebase)[source]#

Plot ICA characteristics for rejected components.

Parameters:
Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.plot_summary_bad_segs(subject_data, reportdir)[source]#

Plot summary of bad channels over subjects.

Parameters:
  • subject_data (list) – list of data for each subject, typically generated by gen_html_data

  • reportdir (str) – Path to report directory. We will save the plot in this directory.

Returns:

path – Path to plot.

Return type:

str

osl_ephys.report.preproc_report.plot_summary_bad_chans(subject_data, reportdir)[source]#

Plot summary of bad channels over subjects.

Parameters:
  • subject_data (list) – list of data for each subject, typically generated by gen_html_data

  • reportdir (str) – Path to report directory. We will save the plot in this directory.

Returns:

path – Path to plot.

Return type:

str

osl_ephys.report.preproc_report.plot_artefact_scan(raw, savebase=None)[source]#

Plot artefact scan.

Parameters:
  • raw (mne.io.Raw) – MNE Raw object.

  • savebase (str) – Base string for saving figures.

Returns:

fpath – Path to saved figure.

Return type:

str

osl_ephys.report.preproc_report.print_scan_summary(raw)[source]#

Print a text summary of an MNE file.

Parameters:

raw (mne.io.Raw) – MNE Raw object.

osl_ephys.report.preproc_report.plot_events(events, event_id, savebase)[source]#
osl_ephys.report.preproc_report.plot_custom_figures(custom_figures, savebase)[source]#