HTML report

In the html report:

  • all the plots produced by MEQ-QC are interactive, they can be scrolled through and enlarged.

  • a few plots from MNE (in ECG and EOG sections) are not interactive.

UML diagrams presenting the flow of the analysis for each module are available here: https://github.com/ANCPLabOldenburg/MEG-QC-code/tree/main/diagrams

meg_qc.plotting.universal_html_report.get_tit_and_unit(m_or_g: str, psd: bool = False)[source]

Return title and unit for a given type of data (magnetometers or gradiometers) and type of plot (psd or not)

Parameters:
  • m_or_g (str) – ‘mag’ or ‘grad’

  • psd (bool, optional) – True if psd plot, False if not, by default False

Returns:

  • m_or_g_tit (str) – ‘Magnetometers’ or ‘Gradiometers’

  • unit (str) – ‘T’ or ‘T/m’ or ‘T/Hz’ or ‘T/m / Hz’

meg_qc.plotting.universal_html_report.keep_fig_derivs(derivs_section: list)[source]

Loop over list of derivs belonging to 1 section, keep only figures to add to report.

Parameters:

derivs_section (list) – A list of QC_derivative objects belonging to 1 section.

Returns:

fig_derivs_section – A list of QC_derivative objects belonging to 1 section with only figures.

Return type:

list

meg_qc.plotting.universal_html_report.make_html_section(derivs_section: list, section_name: str, report_strings: dict)[source]

Create 1 section of html report. 1 section describes 1 metric like “ECG” or “EOG”, “Head position” or “Muscle”… Functions does:

  • Add section title

  • Add user notification if needed (for example: head positions not calculated)

  • Loop over list of derivs belonging to 1 section, keep only figures

  • Put figures one after another with description under. Description should be set inside of the QC_derivative object.

Parameters:
  • derivs_section (list) – A list of QC_derivative objects belonging to 1 section.

  • section_name (str) – The name of the section like “ECG” or “EOG”, “Head position” or “Muscle”…

  • report_strings (dict) – A dictionary with strings to be added to the report: general notes + notes about every measurement (when it was not calculated, for example). This is not a detailed description of the measurement.

Returns:

html_section_str – The html string of 1 section of the report.

Return type:

str

meg_qc.plotting.universal_html_report.make_joined_report(sections: dict, report_strings: dict)[source]

Create report as html string with all sections. Currently make_joined_report_mne is used.

Parameters:
  • sections (dict) – A dictionary with section names as keys and lists of QC_derivative objects as values.

  • sreport_strings (dict) – A dictionary with strings to be added to the report: general notes + notes about every measurement (when it was not calculated, for example). This is not a detailed description of the measurement.

Returns:

html_string – The html whole string of the report.

Return type:

str

meg_qc.plotting.universal_html_report.make_joined_report_mne(raw, sections: dict, report_strings: dict, default_settings: dict)[source]

Create report as html string with all sections and embed the sections into MNE report object.

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

  • sections (dict) – A dictionary with section names as keys and lists of QC_derivative objects as values.

  • report_strings (dict) – A dictionary with strings to be added to the report: general notes + notes about every measurement (when it was not calculated, for example). This is not a detailed description of the measurement.

  • default_settings (dict) – A dictionary with default settings.

Returns:

report – The MNE report object with all sections.

Return type:

mne.Report

meg_qc.plotting.universal_html_report.simple_metric_basic(metric_global_name: str, metric_global_description: str, metric_global_content_mag: dict, metric_global_content_grad: dict, metric_local_name: str | None = None, metric_local_description: str | None = None, metric_local_content_mag: dict | None = None, metric_local_content_grad: dict | None = None, display_only_global: bool = False, psd: bool = False, measurement_units: bool = True)[source]

Basic structure of simple metric for all measurements.

Parameters:
  • metric_global_name (str) – Name of the global metric.

  • metric_global_description (str) – Description of the global metric.

  • metric_global_content_mag (dict) – Content of the global metric for the magnitometers as a dictionary. Content is created inside of the module for corresponding measurement.

  • metric_global_content_grad (dict) – Content of the global metric for the gradiometers as a dictionary. Content is created inside of the module for corresponding measurement.

  • metric_local_name (str, optional) – Name of the local metric, by default None (in case of no local metric is calculated)

  • metric_local_description (str, optional) – Description of the local metric, by default None (in case of no local metric is calculated)

  • metric_local_content_mag (dict, optional) – Content of the local metric for the magnitometers as a dictionary, by default None (in case of no local metric is calculated) Content is created inside of the module for corresponding measurement.

  • metric_local_content_grad (dict, optional) – Content of the local metric for the gradiometers as a dictionary, by default None (in case of no local metric is calculated) Content is created inside of the module for corresponding measurement.

  • display_only_global (bool, optional) – If True, only global metric is displayed, by default False This parameter is set to True in case we dont need to display any info about local metric at all. For example for muscle artifacts. In case we want to display some notification about local metric, but not the actual metric (for example it failed to calculate for a reason), this parameter is set to False and metric_local_description should contain that notification and metric_local_name - the name of missing local metric.

  • psd (bool, optional) – If True, the metric is done for PSD and the units are changed accordingly, by default False

  • measurement_units (bool, optional) – If True, the measurement units are added to the metric, by default True

Returns:

simple_metric – Dictionary with the whole simple metric to be converted into json in main script.

Return type:

dict