Skip to content

Concatenate mne.Reports #12858

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

Open
sappelhoff opened this issue Sep 17, 2024 · 9 comments · May be fixed by #13223
Open

Concatenate mne.Reports #12858

sappelhoff opened this issue Sep 17, 2024 · 9 comments · May be fixed by #13223
Labels

Comments

@sappelhoff
Copy link
Member

sappelhoff commented Sep 17, 2024

Describe the new feature or enhancement

I have a pipeline that creates an mne.Report per subject and per "run". I made up my mind "after the fact" and now want to combine the "runs" per subject in a single report.

It would therefore be nice if I could simply load the reports, and concatenate them into a single report.

Describe your proposed implementation

Not sure how the specifics of this would work.

Describe possible alternatives

The alternative is, that I re-write my pipeline to write one report per subject, including all "runs", from the beginning.

Additional context

No response

@sappelhoff sappelhoff added the ENH label Sep 17, 2024
@larsoner
Copy link
Member

No opposition in principle. In practice might be tricky because of DOM stuff, templating, and dealing with potential duplicates. But first supporting the case where there are no duplicates in the DOM IDs I think it shouldn't be too bad.

@Randomidous
Copy link
Contributor

Hey @larsoner and @sappelhoff ,

I was thinking about picking this up in my free time but it would help me to narrow down the functionality a bit @larsoner .
Would a function in mne/report/report.py that does nothing else but appending reports using beautifulsoup4 do the job?

@larsoner
Copy link
Member

Unfortunately that wouldn't work to concat the mne.Report objects themselves, it would only work to concatenate the generated HTML

@Randomidous
Copy link
Contributor

Sorry for the ambiguous language. I meant concatenating html files not reports.
I was thinking of something like this: #13223

I have attached the report resulting from running mne.report.tests.test_report.test_concatenate_reports():
combined.pdf

@wmvanvliet
Copy link
Contributor

Wouldn't it be way easier to merge/concatenate the mne.Report objects themselves? And then call .save("big_report.html") on the result. That would enable a workflow in which you have the reports of individual subjects as .h5 files (as well as .html if that is convenient) and then at the end load all the .h5 files, concatenate them, and then save the final .html.

@Randomidous
Copy link
Contributor

@wmvanvliet That would work nicely, but I think the inquiry was regarding what to do once the reports are already saved:

I made up my mind "after the fact" and now want to combine the "runs" per subject in a single report.

@sappelhoff
Copy link
Member Author

When I first opened this issue, I actually DID save all reports in html and h5, so what @wmvanvliet suggests would have worked there, and I believe it is a nice way to deal with the issue.

Potentially there is a place for both functions: concatenating the HTMLs themselves, as well as the workflow that Marijn suggested? What do you all think?

@drammock
Copy link
Member

Personally I don't feel that MNE should be doing things like munging HTML files. It feels pretty squarely out of scope for a neuroscience package. Merging report .h5 files is slightly better, but even there I'd be tempted to write a recipe for how to do it yourself, and post that as a how-to example on our doc site, rather than adding new functionality to the public API.

@wmvanvliet
Copy link
Contributor

wmvanvliet commented Apr 24, 2025

@wmvanvliet That would work nicely, but I think the inquiry was regarding what to do once the reports are already saved:

If you save them as .h5 you can read them back in as mne.Report objects. Nothing is stopping you from saving both a copy in .h5 and one in .html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants