Skip to content

ENH: Validate frequencies and add docstring warning in TFR array classes (#14605) - #14606

Open
ishaaaan17 wants to merge 1 commit into
mne-tools:mainfrom
ishaaaan17:enh/tfr-array-freqs-check
Open

ishaaaan17 wants to merge 1 commit into
mne-tools:mainfrom
ishaaaan17:enh/tfr-array-freqs-check

Conversation

@ishaaaan17

@ishaaaan17 ishaaaan17 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Reference issue (if any)

Closes #14605. Follow-up to #14598.

What does this implement/fix?

As discussed with @tsbinns in #14605, this expands the input validation and docstring warnings from #14598 to AverageTFRArray, EpochsTFRArray, and RawTFRArray:

  • Validate in BaseTFR._check_state() (shared by all three *TFRArray classes) that frequencies are non-negative (freqs >= 0) and do not exceed the Nyquist frequency (sfreq / 2).
  • Reuse the warn_spectrum_array docdict entry via @fill_doc_static at the top of the Notes section in AverageTFRArray, EpochsTFRArray, and RawTFRArray.
  • Add frequency validation checks inside test_tfr_init_errors.

Additional information

Style (ruff), static docstring (check_static_docs.py), and towncrier changelog (14606.bugfix.rst) checks pass, and test_tfr.py, test_topo.py, and test_topomap.py pass locally after the final edit.

AI Assistance Disclosure: I planned the approach based on #14598 and reviewed all changes; I used Antigravity (Gemini) to draft the edits, integrate the tests, and verify style, changelog, and static-doc checks.

@tsbinns tsbinns left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for opening this @ishaaaan17. That was a typo in the issue to say it expects all freq > 0. It should have been >= 0. Apologies, I have updated the issue to reflect this.

Although our Morlet and multitaper TFR computations don't return a DC bin, it is perhaps too strict to completely prevent this.

Apart from that, this would be good to merge.

@ishaaaan17
ishaaaan17 force-pushed the enh/tfr-array-freqs-check branch from 51308d7 to 8acfd18 Compare November 28, 2026 16:41
@ishaaaan17

Copy link
Copy Markdown
Contributor Author

thanks @tsbinns, updated the check to freqs >= 0 and reverted the dummy 0 hz test changes since 0 hz is allowed now.

@ishaaaan17
ishaaaan17 requested a review from tsbinns November 28, 2026 16:48

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand input validation for TFR array containers

2 participants