ENH: Allow mne.Report section reordering
larsoner opened this issue · 1 comments
Currently with mne.Report
you can:
- Add new sections, which get placed at the end
- Remove sections
- 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:
-
Expose a
report.get_contents
that is probably just a public version of this:mne-python/mne/report/report.py
Line 968 in acab264
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). -
Expose a
report.reorder(order)
whereorder
must satisfynp.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.
seems like a good idea to me! The only thought I had was that it might be easier to allow re-ordering via click-and-drag when viewing the report, but (as we discussed briefly today) this would not have persistence.