mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

ENH: Add param to report.add_epochs to report reject/flat

Open larsoner opened this issue 1 year ago • 5 comments
trafficstars

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.

larsoner avatar Jan 30 '24 17:01 larsoner

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,
    ):

Forchapeatl avatar Feb 24 '24 01:02 Forchapeatl

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.

larsoner avatar Feb 26 '24 18:02 larsoner

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,
            )

jairajmahadev avatar Mar 05 '24 18:03 jairajmahadev

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?

larsoner avatar Mar 06 '24 20:03 larsoner