Skip to content

Conversation

@shamshad-ansari
Copy link

…s (#12396)

Reference issue (if any)

Fixes #12396.

What does this implement/fix?

This PR automatically includes reject and flat thresholds in the epochs report when add_epochs() is called. Previously, while the report showed which epochs were dropped (the Drop Log), it did not document the specific criteria used to drop them unless the user manually added that information via add_html().

Now, the report automatically retrieves these values from the Epochs object, providing a complete and transparent record of the preprocessing steps.

Key Changes:

  • Automatic Extraction: Uses getattr() to safely retrieve reject and flat dictionaries directly from the epochs instance.
  • Contextual Placement: Information is only added if epochs._bad_dropped is True, ensuring the report stays clean for data that hasn't undergone rejection.
  • Standardized Styling: Uses the existing div_klass="epochs" and <code> tags to match the MNE-Python report aesthetic.
  • Improved Reproducibility: Displays the thresholds immediately preceding the Drop Log to provide a clear "Cause and Effect" relationship in the documentation.

Additional information

  • This is my first contribution to MNE-Python.
  • Verified the fix using a custom script and confirmed the HTML renders correctly across different threshold settings.
  • Passed existing tests in mne/report/tests/test_report.py (25 passed).
  • Code has been linted and checked with ruff.
  • A towncrier entry will be added as a separate commit once the PR number is assigned.

@shamshad-ansari
Copy link
Author

Visual Comparison

Before

The report showed the Drop Log but not the rejection criteria that caused the drops:

Before - Missing rejection thresholds

After

Now the rejection and flat thresholds are automatically displayed above the Drop Log:

After - Rejection and flat thresholds automatically added

@shamshad-ansari shamshad-ansari force-pushed the enh/report_epoch_thresholds branch from b8ad333 to 9de757b Compare January 28, 2026 02:21
@larsoner
Copy link
Member

Was this PR AI-generated? Please disclose the extent of AI usage

@shamshad-ansari
Copy link
Author

Was this PR AI-generated? Please disclose the extent of AI usage

I used an LLM to help draft the retrieval logic. However, I have manually verified the implementation by:

Running the existing test suite (pytest mne/report/tests/test_report.py).

Verifying the rendered HTML output using a test script (see attached screenshots).

Ensuring the code follows the project's style guidelines via ruff.

Please let me know if there are specific changes to the logic or formatting you'd like me to make!

@larsoner
Copy link
Member

Okay we are still deliberating the use of LLMs in contributions, it might take a while to get back to this!

@larsoner larsoner added the needs-discussion issues requiring a dev meeting discussion before the way forward is clear label Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-discussion issues requiring a dev meeting discussion before the way forward is clear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants