Skip to content

ENH: Allow mne.Report section reordering #12424

@larsoner

Description

@larsoner

Currently with mne.Report you can:

  1. Add new sections, which get placed at the end
  2. Remove sections
  3. Replace existing sections

In MNE-BIDS-Pipeline we have an issue where we parallelize over runs and it messes up report order. In serial mode, run 1 gets processed, then 2, etc. But in parallel mode, sometimes run 4 finishes before run 1, so its summary gets added to the report first, and thus gets placed first in the HTML. There is no way to fix this other than removing and re-adding the sections in the right order, which is cumbersome.

To fix this, I suggest that we provide some way to reorder sections. One option would be:

  1. Expose a report.get_contents that is probably just a public version of this:

    def _content_as_html(self):

    This gives the HTML, DOM IDs, titles, and tags, but I think a more natural order for the public function would be (titles, tags, html) (no need for DOM IDs I think, this is mostly for our linking and HTML structure convenience).

  2. Expose a report.reorder(order) where order must satisfy np.array_equal(np.unique(order), np.arange(len(self._contents)), and the contents are reordered appropriately.

That way users can 1) get access to the stuff they've added already, 2) figure out what reordering they want to apply, and 3) apply it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions