mne-python
mne-python copied to clipboard
ENH: Add param to report.add_epochs to report reject/flat
I think the value of the "reject" parameter should be included via upstream changes to mne.Report.add_epochs().
Originally posted by @hoechenberger in https://github.com/mne-tools/mne-bids-pipeline/issues/839#issuecomment-1917498418
In other words, epochs.reject and maybe epochs.flat could be useful to allow opt-in to reporting in add_epochs so people know what rejection has been done. See linked PR for how it's done in MNE-BIDS-Pipeline for example.
Hello @larsoner , I am Forcha Pearl from Cameroon. It's a pleasure meeting you. I would love to participate in GSOC 2024 under mne-tools, Please is this what you mean ?
@fill_doc
def add_epochs(
self,
epochs,
title,
*,
psd=True,
projs=None,
image_kwargs=None,
topomap_kwargs=None,
drop_log_ignore=("IGNORED",),
tags=("epochs",),
replace=False,
+ reject=epochs.reject,
):
Not exactly -- I actually don't think we need any new parameter, but should just automatically always add a subsection that is basically the contents of this:
https://github.com/mne-tools/mne-bids-pipeline/blob/61b35530b16a61753b25fa663b575d9b2f7a6ed5/mne_bids_pipeline/steps/preprocessing/_09_ptp_reject.py#L215-L221
So just a new add_html in mne.Report._add_epochs, probably inside this conditional:
https://github.com/mne-tools/mne-python/blob/ae6e55e8eb41f080d6c209c129bb86ecdb2fc30d/mne/report/report.py#L3939
Probably need one for reject and one for flat.
Hello @larsoner, this is my first time trying to solve an issue. From what I understood, is this correct? and sorry if I'm totally incorrect.
if epochs._bad_dropped:
self.add_html(
html=f"<code>{reject}</code>",
title=f"{kind} thresholds",
section=title,
replace=True,
tags=tags,
)
report.add_html(
html=f"<code>{flat}</code>",
title=f"{kind} thresholds",
section=title,
replace=True,
tags=tags,
)
Something like that. Not sure what kind is in your example -- that might be MNE-BIDS-Pipeline specific. Maybe try implementing something and running the report tutorial and see if it works as expected?