From 56e522ba303fe01a25a2a0d5d7507639a83fe02c Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 18 Oct 2024 14:06:44 -0400 Subject: [PATCH] ENH: Improve report usability (#12901) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel McCloy --- doc/changes/devel/12901.bugfix.rst | 1 + doc/changes/devel/12901.newfeature.rst | 8 + mne/html_templates/report/html.html.jinja | 8 +- mne/html_templates/report/image.html.jinja | 26 +- mne/html_templates/report/section.html.jinja | 8 +- mne/html_templates/report/slider.html.jinja | 12 +- mne/report/report.py | 444 ++++++++++++++----- mne/report/tests/test_report.py | 79 +++- mne/utils/docs.py | 22 +- mne/viz/_3d.py | 60 ++- mne/viz/tests/test_3d.py | 6 +- tutorials/intro/70_report.py | 20 +- tutorials/preprocessing/59_head_positions.py | 2 +- 13 files changed, 510 insertions(+), 186 deletions(-) create mode 100644 doc/changes/devel/12901.bugfix.rst create mode 100644 doc/changes/devel/12901.newfeature.rst diff --git a/doc/changes/devel/12901.bugfix.rst b/doc/changes/devel/12901.bugfix.rst new file mode 100644 index 00000000000..d68f70f7141 --- /dev/null +++ b/doc/changes/devel/12901.bugfix.rst @@ -0,0 +1 @@ +:class:`mne.Report` HDF5 files are now written in ``mode='a'`` (append) to allow users to store other data in the HDF5 files, by `Eric Larson`_. diff --git a/doc/changes/devel/12901.newfeature.rst b/doc/changes/devel/12901.newfeature.rst new file mode 100644 index 00000000000..8d0137fce78 --- /dev/null +++ b/doc/changes/devel/12901.newfeature.rst @@ -0,0 +1,8 @@ +Improved reporting and plotting options: + +- :meth:`mne.Report.add_projs` can now plot with :func:`mne.viz.plot_projs_joint` rather than :func:`mne.viz.plot_projs_topomap` +- :class:`mne.Report` now has attributes ``img_max_width`` and ``img_max_res`` that can be used to control image scaling. +- :class:`mne.Report` now has an attribute ``collapse`` that allows collapsing sections and/or subsections by default. +- :func:`mne.viz.plot_head_positions` now has a ``totals=True`` option to show the total distance and angle of the head. + +Changes by `Eric Larson`_. diff --git a/mne/html_templates/report/html.html.jinja b/mne/html_templates/report/html.html.jinja index 62b9da07911..a9b4f881f12 100644 --- a/mne/html_templates/report/html.html.jinja +++ b/mne/html_templates/report/html.html.jinja @@ -1,7 +1,6 @@
-
- - -
+
{{ html | safe }}
diff --git a/mne/html_templates/report/image.html.jinja b/mne/html_templates/report/image.html.jinja index 06a6855ace5..41cf47e1395 100644 --- a/mne/html_templates/report/image.html.jinja +++ b/mne/html_templates/report/image.html.jinja @@ -1,17 +1,17 @@ {% extends "section.html.jinja" %} {% block html_content %} -
- {% if image_format == 'svg' %} -
- {{ img|safe }} -
- {% else %} - {{ title }} - {% endif %} +
+ {% if image_format == 'svg' %} +
+ {{ img|safe }} +
+ {% else %} + {{ title }} + {% endif %} - {% if caption is not none %} -
{{ caption }}
- {% endif %} -
+ {% if caption is not none %} +
{{ caption }}
+ {% endif %} +
{% endblock html_content %} diff --git a/mne/html_templates/report/section.html.jinja b/mne/html_templates/report/section.html.jinja index 584ff86dda9..baddf7dd8b6 100644 --- a/mne/html_templates/report/section.html.jinja +++ b/mne/html_templates/report/section.html.jinja @@ -1,7 +1,6 @@
-
- - -
+
{% block html_content %} {% for html in htmls %} diff --git a/mne/html_templates/report/slider.html.jinja b/mne/html_templates/report/slider.html.jinja index 58ee8a9f9fc..fab7f56472d 100644 --- a/mne/html_templates/report/slider.html.jinja +++ b/mne/html_templates/report/slider.html.jinja @@ -1,8 +1,7 @@
-
- -
+
- -