Skip to content

Conversation

@zhijingz
Copy link
Contributor

…es #13364)

Reference issue (if any)

Fixes #13364

What does this implement/fix?

psd_array_welch

  • Added an explicit early check for Inf values inside the analyzed span.
  • Replaced an internal assert with a user-facing ValueError when NaN masks are not aligned across channels.
  • Retained existing intended behavior that allows “sentinel” NaNs — aligned across channels — to mark annotation boundaries without error.

ICA.fit

  • Added an early ValueError guard when input data contain any NaN or Inf, producing a clear message instead of downstream runtime warnings.

Additional information

@welcome
Copy link

welcome bot commented Nov 13, 2025

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@zhijingz
Copy link
Contributor Author

Hi! First-time contributor here. I’ve rebased on current main, pre-commit passes locally, and targeted tests are green:

pytest -q mne/time_frequency/tests -k psd → 21 passed, 6 skipped
pytest -q mne/preprocessing/tests -k ica → 1 passed

Could someone please approve CI to run on this PR? Thanks!

@larsoner larsoner added this to the 1.11 milestone Nov 13, 2025
@zhijingz
Copy link
Contributor Author

Hi, I revised the contritbution doc - anything else I need to do for the workflow to be approved?

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few comments/suggestions about specific bits of the code/tests. Additional high-level comments:

#13364 (comment) suggested that we error for ICA.fit when there are NaNs present, but for PSD we should warn if NaNs are on specific channels and compute the PSD for the other channels that have good data. I see two new ValueErrors and no new warnings in the time_frequency code, so it seems like you're doing something different from what @larsoner recommended.

@zhijingz
Copy link
Contributor Author

Hi thanks for the suggestions - I've included the suggestions into this updated version + psd part now warns on channels with nan instead of raising but still computes psd for valid channels. Let me know your feedback on these new changes

@larsoner
Copy link
Member

Pushed a tiny commit to use mne.utils.warn instead of warnings.warn because our version does some stacklevel and logger.level-based magic. Then pushed a commit to get CircleCI to run all examples to make sure none break because of this PR 🤞

I'll watch it and push another commit to fix any broken examples so this can land in 1.11 which we want to release in the next day or so. Thanks in advance @zhijingz !

* upstream/main:
  ENH: Parse EyeLink BUTTON Events (e.g. from a game controller) (mne-tools#13499)
  FIX: Fix regression with mne.viz.plot_evoked (mne-tools#13481)
  DOC: related software doc (mne-tools#13498)
  FIX: Replace use of deprecated Numpy func in GDF reader  (Supersedes mne-tools#13415) (mne-tools#13497)
  DOC: Link to membership from governance page (mne-tools#13496)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#13495)
  BUG: Fix issue with Montage.plot (mne-tools#13494)
@larsoner larsoner enabled auto-merge (squash) November 20, 2025 16:42
@larsoner larsoner merged commit 08f64a2 into mne-tools:main Nov 20, 2025
32 checks passed
@welcome
Copy link

welcome bot commented Nov 20, 2025

🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Insufficient checking for isfinite in compute_psd and ica.fit

3 participants