Fix transition bandwidth reported in 'filter too short' error (#11406)#14005
Open
CedricConday wants to merge 3 commits into
Open
Fix transition bandwidth reported in 'filter too short' error (#11406)#14005CedricConday wants to merge 3 commits into
CedricConday wants to merge 3 commits into
Conversation
…-tools#11406) The error reported transition * sfreq / 2.0, but transition is already half the Nyquist-normalized width, so it displayed half the actual transition band (e.g. 0.50 Hz for a requested 1.0 Hz). Report transition * sfreq. Adds a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11406
What was wrong
When a requested FIR
filter_lengthis too short, the raised error reports the transition bandwidth astransition * sfreq / 2.0. Buttransitionis computed as(prev_freq - this_freq) / 2.0where the frequencies are already normalized to the Nyquist rate, so it is already half the Nyquist-normalized width. Multiplying bysfreq / 2.0therefore displays half the real transition band — e.g. a requestedl_trans_bandwidth=1.0Hz is reported as0.50 Hz.this_N(the required length) is computed correctly; only the message is wrong.Fix
Report
transition * sfreq, which is the true transition bandwidth.Test
Adds
test_filter_too_short_error_reports_correct_transition: a too-short filter withl_trans_bandwidth=1.0now reports1.00 Hz transition band. Verified it reports0.50 Hzonmainand1.00 Hzwith this change.AI-assisted, human-reviewed — I'm an AI engineer; I find, fix, and test with AI, then review and verify before opening.