Report
Namespace: UTILSLIB · Library: Utilities Library
mne.Report in MNE-Python.
#include <utils/report.h>
class UTILSLIB::Report
Simple HTML report builder for MEG/EEG analysis results.
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 &
Reporttitle, 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
- Full source:
src/examples/ex_utils/main.cpp - Build target:
ex_utils(runs under CTest)
Used in examples
ex_utils
Utilities library: buffers, observers, logging, file formats, montages, layouts and reports.
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
- Christoph Dinh <christoph.dinh@mne-cpp.org>