Skip to main content

Report

Namespace: UTILSLIB  ·  Library: Utilities Library

Python equivalent

mne.Report in MNE-Python.

#include <utils/report.h>

class UTILSLIB::Report

Simple HTML report builder for MEG/EEG analysis results.

src/examples/ex_utils/main.cpp
Report report("Example report");
report.addText("Summary", "All utilities were exercised.");
report.addTable("Montage", {"Electrode", "z (m)"}, {{"Cz", "0.087"}, {"Fp1", "0.033"}});
const QString html = report.toHtml();
report.save(dir.filePath("report.html"));

Public Methods​

Report(sTitle)​

Construct a report with a title.

Parameters:

  • sTitle : const QString & Report title, used for the HTML page title and main heading.

addText(sTitle, sContent)​

Add a text section.

Parameters:

  • sTitle : const QString & Section title.

  • sContent : const QString & Text content (plain text or HTML).


addTable(sTitle, headers, rows)​

Add a table section.

Parameters:

  • sTitle : const QString & Section title.

  • headers : const QStringList & Column headers.

  • rows : const QList< QStringList > & Row data (list of string lists).


addKeyValue(sTitle, pairs)​

Add a key-value section.

Parameters:

  • sTitle : const QString & Section title.

  • pairs : const QList< QPair< QString, QString > > & List of (key, value) pairs.


addCode(sTitle, sCode)​

Add a preformatted code block.

Parameters:

  • sTitle : const QString & Section title.

  • sCode : const QString & Code text; it is HTML-escaped and wrapped in a preformatted block.


sectionCount()​

Get the number of sections.

Returns:

  • int — Number of sections added so far.

toHtml()​

Generate the full HTML string.

Returns:

  • QString — Self-contained HTML document containing the title and all sections.

save(sPath)​

Save the report to an HTML file.

Parameters:

  • sPath : const QString & Output file path.

Returns:

  • bool — true if successful.

title()​

Get the report title.

Returns:

  • const QString & — Title passed at construction.

Example​

Used in examples​

ex_utils​

Utilities library: buffers, observers, logging, file formats, montages, layouts and reports.

src/examples/ex_utils/main.cpp, line 265
Report report("Example report");
report.addText("Summary", "All utilities were exercised.");
report.addTable("Montage", {"Electrode", "z (m)"}, {{"Cz", "0.087"}, {"Fp1", "0.033"}});
const QString html = report.toHtml();
report.save(dir.filePath("report.html"));
ok &= expect(report.sectionCount() == 2 && html.contains("<table") && html.contains("Fp1") && QFile::exists(dir.filePath("report.html")),
"Report renders text and table sections to HTML");

Authors of this file​