ENH Add CUDA support for Hilbert transforms - #14164
Merged
Merged
Conversation
viranovskaya
marked this pull request as ready for review
August 17, 2026 06:02
viranovskaya
requested review from
agramfort,
drammock and
larsoner
as code owners
August 17, 2026 06:02
larsoner
approved these changes
Aug 23, 2026
larsoner
left a comment
Member
There was a problem hiding this comment.
Sorry for the slow response -- looks good to me and I tested locally with cupy-13x and it worked (when I set MNE_USE_CUDA=true properly). I'll make these minor edits then merge, thanks in advance @viranovskaya !
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
larsoner
reviewed
Aug 23, 2026
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
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.
Related to #13993 and #13994.
This implements the alternative suggested in the discussion: CUDA support in
apply_hilbertinstead of a second public job-control parameter inannotate_muscle_zscore.When
n_jobs="cuda"is requested, the analytic signal is computed with CuPy FFT and transferred back to NumPy. If CUDA cannot be initialized, the existing CPU implementation is used with one job. This allowsannotate_muscle_zscore(..., n_jobs="cuda")to use the same setting for filtering and the Hilbert transform without exposing an implementation-specific parameter.The numerical tests compare the FFT implementation with
scipy.signal.hilbertfor odd and even lengths, zero padding, analytic signals, and envelopes. A regression test covers the full muscle-annotation call.Local checks:
This was tested on a machine without CUDA hardware. The CPU fallback and numerical implementation are covered locally, but the actual CuPy device path still needs CUDA-backed verification.
Closes #13993
Closes #13994