Enable IRASA multi-method support and add regression tests - #362
Open
camiloberutti wants to merge 1 commit into
Open
Enable IRASA multi-method support and add regression tests#362camiloberutti wants to merge 1 commit into
camiloberutti wants to merge 1 commit into
Conversation
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.
Summary
This PR fixes
compute_irasainneurodsp.aperiodic.irasato support all spectral estimation methods (welch,medfilt,multitaper,wavelet) instead of onlywelch. Currently,compute_irasaunconditionally injects thenpersegparameter, which is invalid for non-Welch methods, causingAssertionErrororKeyError.Problem Statement
Users cannot use
compute_irasawith methods other than Welch because:method-aware parameter injection: The function always addsnpersegregardless of the spectral method, violating parameter constraints formedfiltandmultitaper.multitaperentry inSPECTRUM_INPUTS: The parameter validation dictionary inpower.pylacks amultitaperkey, causingKeyErrorwhen the method is used.Error Examples (Before Patch)
Changes
File 1:
neurodsp/aperiodic/irasa.pyChange 1.1: Method-aware
nperseginjection (line ~72)Change 1.2: Robust frequency-grid alignment for resampled spectra (lines ~86–96)
Change 1.3: Use
np.nanmedianinstead ofnp.median(line ~104)File 2:
neurodsp/spectral/power.pyChange 2.1: Add
multitapertoSPECTRUM_INPUTSdictionary (line ~80)Testing
New test file:
test_irasa_multimethod.py(see attached)compute_irasawith all four methodsUsage example after patch: