Skip to content

ENH: Support segmented Hilbert transformation - #14642

Closed
VivinAT04 wants to merge 3 commits into
mne-tools:mainfrom
VivinAT04:enh/segmented-hilbert-transform
Closed

VivinAT04 wants to merge 3 commits into
mne-tools:mainfrom
VivinAT04:enh/segmented-hilbert-transform

Conversation

@VivinAT04

Copy link
Copy Markdown
Contributor

While going through the Hilbert transformation in our MNE, I looked at that when a single missing sample can cause the entire transformed signal to become NaN. I wanted to check whether available parts of the signal could be processed without filling in the missing values. So i developed an nan_policy="segment" parameter that can transforms valid segments independently while keeping the default behaviour unchanged.

I tested this approach using synthetic signals and real EEG data with artificial gaps, with 555 tests passing and 48 skipped. This current approach supports CPU processing and may introduce artifacts near segment boundaries. I used ChatGPT to help understand the existing implementation. But I have made the changes on my own, understood the actual implementation and verified the results through local testing.

@VivinAT04
VivinAT04 requested a review from larsoner as a code owner December 4, 2026 21:39
@larsoner

larsoner commented Dec 5, 2026

Copy link
Copy Markdown
Member

I would assume YAGNI on this, and only add it if users ask. (I think filtering is common enough it was worth adding there, but hilbert is pretty niche functionality I think, so the intersection with NaN even more so...)

@VivinAT04

Copy link
Copy Markdown
Contributor Author

Thanks Eric, that makes sense. I wanted to explore whether the available signal could be preserved when missing values are present. I understand your point about adding functionality only when there is a practical need for it. We can leave this PR for now, and we can revisit it if users request it in the future

@VivinAT04 VivinAT04 closed this Dec 5, 2026
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.

2 participants