Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: In Report, allow to add multiple figure or image elements to the same content block ("section") #10694

Merged
merged 9 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Enhancements

- Add timeformat ``YYYY/MM/DD`` to ``mne.io.ctf.info._convert_time`` (:gh:`10674` by `Simon Kern`_)

- :meth:`mne.Report.add_figure` and :meth:`mne.Report.add_image` gained a new parameter, ``section``, allowing to put multiple figures or images into the same "content block". Previously, the only way to group figures and images was by means of a slider, which sometimes made content hard to discover. The slider remains available as an alternative. (:gh:`10694` by `Richard Höchenberger`_)

Bugs
~~~~

Expand Down
8 changes: 8 additions & 0 deletions mne/html_templates/report/bem.html.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "section.html.jinja" %}
{% block html_content %}
<div class="row">
{{ html_slider_axial | safe }}
{{ html_slider_sagittal | safe }}
{{ html_slider_coronal | safe }}
</div>
{% endblock html_content %}
30 changes: 6 additions & 24 deletions mne/html_templates/report/code.html.jinja
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
<div class="accordion-item code" id="{{ id }}" data-mne-tags="{% for tag in tags %} {{ tag }} {% endfor %}">
<div class="accordion-header" id="accordion-header-{{ id }}">
<button class="accordion-button pt-1 pb-1" type="button" data-bs-toggle="collapse"
data-bs-target="#accordion-collapse-{{ id }}" aria-expanded="true" aria-controls="accordion-collapse-{{ id }}">
<div class="w-100">
<span class="me-auto">{{ title }}</span>
{% for tag in tags %}
<span class="badge bg-primary rounded-pill float-end me-1" data-mne-tag="{{ tag }}">
{{ tag }}
</span>
{% endfor %}
</div>
</button>
</div>

<div id="accordion-collapse-{{ id }}" class="accordion-collapse collapse show"
aria-labelledby="accordion-header-{{ id }}">
<div class="accordion-body">
<pre class="my-0">
<code class="language-{{ language }}">{{ code }}</code>
</pre>
</div>
</div>
</div>
{% extends "section.html.jinja" %}
{% block html_content %}
<pre class="my-0">
<code class="language-{{ language }}">{{ code }}</code>
</pre>
{% endblock html_content %}
27 changes: 0 additions & 27 deletions mne/html_templates/report/epochs.html.jinja

This file was deleted.

26 changes: 0 additions & 26 deletions mne/html_templates/report/evoked.html.jinja

This file was deleted.

28 changes: 5 additions & 23 deletions mne/html_templates/report/forward.html.jinja
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
<div class="accordion-item forward-solution" id="{{ id }}" data-mne-tags="{% for tag in tags %} {{ tag }} {% endfor %}">
<div class="accordion-header" id="accordion-header-{{ id }}">
<button class="accordion-button pt-1 pb-1" type="button" data-bs-toggle="collapse"
data-bs-target="#accordion-collapse-{{ id }}" aria-expanded="true" aria-controls="accordion-collapse-{{ id }}">
<div class="w-100">
<span class="me-auto">{{ title }}</span>
{% for tag in tags %}
<span class="badge bg-primary rounded-pill float-end me-1" data-mne-tag="{{ tag }}">
{{ tag }}
</span>
{% endfor %}
</div>
</button>
</div>

<div id="accordion-collapse-{{ id }}" class="accordion-collapse collapse show"
aria-labelledby="accordion-header-{{ id }}">
<div class="accordion-body">
{{repr | safe}}
{{sensitivity_maps | safe }}
</div>
</div>
</div>
{% extends "section.html.jinja" %}
{% block html_content %}
{{repr | safe}}
{{sensitivity_maps | safe}}
{% endblock html_content %}
29 changes: 0 additions & 29 deletions mne/html_templates/report/ica.html.jinja

This file was deleted.

49 changes: 15 additions & 34 deletions mne/html_templates/report/image.html.jinja
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
<div class="accordion-item {{ div_klass }}" id="{{ id }}" data-mne-tags="{% for tag in tags %} {{ tag }} {% endfor %}"
{% if not show %}style="display: none" {% endif %}>
<div class="accordion-header" id="accordion-header-{{ id }}">
<button class="accordion-button pt-1 pb-1" type="button" data-bs-toggle="collapse"
data-bs-target="#accordion-collapse-{{ id }}" aria-expanded="true" aria-controls="accordion-collapse-{{ id }}">
<div class="w-100">
<span class="me-auto">{{ title }}</span>
{% for tag in tags %}
<span class="badge bg-primary rounded-pill float-end me-1" data-mne-tag="{{ tag }}">
{{ tag }}
</span>
{% endfor %}
</div>
</button>
{% extends "section.html.jinja" %}
{% block html_content %}
<figure class="figure mx-auto d-block">
{% if image_format == 'svg' %}
<div class="d-flex justify-content-center">
{{ img }}
</div>
{% else %}
<img class="figure-img img-fluid rounded mx-auto my-0 d-block" alt="{{ title }}"
src="data:image/{{ image_format }};base64,{{ img }}">
{% endif %}

<div id="accordion-collapse-{{ id }}" class="accordion-collapse collapse show"
aria-labelledby="accordion-header-{{ id }}">
<div class="accordion-body">
<figure class="figure mx-auto d-block">
{% if image_format == 'svg' %}
<div class="d-flex justify-content-center">
{{ img }}
</div>
{% else %}
<img class="figure-img img-fluid rounded mx-auto my-0 d-block" alt="{{ title }}"
src="data:image/{{ image_format }};base64,{{ img }}">
{% endif %}

{% if caption is not none %}
<figcaption class="figure-caption text-center">{{ caption }}</figcaption>
{% endif %}
</figure>
</div>
</div>
</div>
{% if caption is not none %}
<figcaption class="figure-caption text-center">{{ caption }}</figcaption>
{% endif %}
</figure>
{% endblock html_content %}
28 changes: 5 additions & 23 deletions mne/html_templates/report/inverse.html.jinja
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
<div class="accordion-item inverse-operator" id="{{ id }}" data-mne-tags="{% for tag in tags %} {{ tag }} {% endfor %}">
<div class="accordion-header" id="accordion-header-{{ id }}">
<button class="accordion-button pt-1 pb-1" type="button" data-bs-toggle="collapse"
data-bs-target="#accordion-collapse-{{ id }}" aria-expanded="true" aria-controls="accordion-collapse-{{ id }}">
<div class="w-100">
<span class="me-auto">{{ title }}</span>
{% for tag in tags %}
<span class="badge bg-primary rounded-pill float-end me-1" data-mne-tag="{{ tag }}">
{{ tag }}
</span>
{% endfor %}
</div>
</button>
</div>

<div id="accordion-collapse-{{ id }}" class="accordion-collapse collapse show"
aria-labelledby="accordion-header-{{ id }}">
<div class="accordion-body">
{{repr | safe}}
{{source_space | safe}}
</div>
</div>
</div>
{% extends "section.html.jinja" %}
{% block html_content %}
{{repr | safe}}
{{source_space | safe}}
{% endblock html_content %}
25 changes: 0 additions & 25 deletions mne/html_templates/report/raw.html.jinja

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="accordion-item covariance" id="{{ id }}" data-mne-tags="{% for tag in tags %} {{ tag }} {% endfor %}">
<div class="accordion-header" id="accordion-header-{{ id }}">
<div class="accordion-item {{ div_klass }}" id="{{ id }}" data-mne-tags="{% for tag in tags %} {{ tag }} {% endfor %}">
<div class="accordion-header" id="accordion-header-{{id}}">
<button class="accordion-button pt-1 pb-1" type="button" data-bs-toggle="collapse"
data-bs-target="#accordion-collapse-{{ id }}" aria-expanded="true" aria-controls="accordion-collapse-{{ id }}">
data-bs-target="#accordion-collapse-{{ id }}" aria-expanded="true" aria-controls="accordion-collapse-{{id}}">
<div class="w-100">
<span class="me-auto">{{ title }}</span>
{% for tag in tags %}
Expand All @@ -13,11 +13,15 @@
</button>
</div>


<div id="accordion-collapse-{{ id }}" class="accordion-collapse collapse show"
aria-labelledby="accordion-header-{{ id }}">
<div class="accordion-body">
{{ matrix | safe }}
{{ svd | safe }}
{% block html_content %}
{% for html in htmls %}
{{ html | safe }}
{% endfor %}
{% endblock %}
</div>
</div>
</div>
6 changes: 3 additions & 3 deletions mne/html_templates/report/toc.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div class="col-2 px-1 position-fixed vh-100 overflow-auto" id="toc">
<h5 class="px-1">Table of contents</h5>
<nav class="nav nav-pills flex-column lh-sm" id="toc-navbar">
{% for element in content_elements %}
<a class="nav-link list-group-item list-group-item-action text-break" href="#{{ element.dom_id }}"
data-mne-tags="{% for tag in element.tags %} {{ tag }} {% endfor %}">{{ element.name }}</a>
{% for title, dom_id, tags_ in titles|zip(dom_ids, tags) %}
<a class="nav-link list-group-item list-group-item-action text-break" href="#{{ dom_id }}"
data-mne-tags="{% for tag in tags_ %} {{ tag }} {% endfor %}">{{ title }}</a>
{% endfor %}
</nav>
</div>
Expand Down
Loading