Repository navigation
ENH: Interpolate blinks in eyetrack channels - #11740
Conversation
- The function lives in mne.preprocessing.eyetracking_pupillometry - added a test - updated the tutorial
This is not a necessary step in this PR (though we should do it). You can make this function channelwise-annotation-aware without changing the reader's behavior.
IIRC the place we left this was "don't make the reader too smart/powerful, read in what's there in the file and then the user can use
I think this is a necessity. I'm not sure if list of strings, regex, callable, etc is best here |
The other way that I can think of doing this is to rely on the eye name being in the
I felt that this was in regards to whether we add a parameter to But I am wondering if anyone still thinks
Maybe this can take some inspiration from events_from_annotations, which allows for |
Relying on the For I would however mention clearly in the tutorial that you can rename the loaded annotations, with an example code snippet.
This is now sparking another question, how does MNE handle a segment during which some of the channels are |
There are a couple places where there could be issues (that I've seen):
|
|
@scott-huberty I have not read all discussion but is a path forward clear? If not, want me to read through and comment and/or we chat at some point? |
I think so:
|
To me the API of this part is still not clear. Possible inputs to a
I'd like @larsoner's perspective on this, I feel like his YAGNI radar is better than mine. (also we need a better param name than |
|
I would start with |
|
@larsoner and I met this afternoon and here's a summary of our plan (for anyone to confirm or object to):
|
|
... and just to add one more point: some of this stuff (e.g., removing the |
- Interpolate over both eyegaze and pupil channels - add match parameter with default "BAD_blink" - expect that each blink annot has ch_name info - remove 'BAD_' from any interpolated annotations - updated test, marked xfail until PR 11746 is merged
…nterpolate_blinks Merged main and resolved conflict stemming from my previous PR, in preprocessing/eyetracking/__init__
- added a test to catch the code block that should raise an error when a blink annotaiton doesnt have ch_name info
- added tests for cases where input to function is incorrect - new tests make sure that warnings and exceptions are raised
britta-wstnr
left a comment
There was a problem hiding this comment.
Looks like this is coming along great! I fixed some typos and had some higher-level questions - see below.
Britta's docstring revisions Co-authored-by: Britta Westner <[email protected]>
- and minor refactor - and added myself to author list of module
- interpolation of gaze channels defaults to false - moved interpolate_blinks function to pupillometry module - added test for new flag - updated API documentation
|
Argh, already hit a bug with one of my files!! If the blink annotation occurs at the start or the end of the recording, interpolation would be impossible (and an error will be raised), and so the blink annotation should be skipped: I'll push something like: |
|
I think we should keep the annotation but adjust the interpolation function to just do nearest neighbor for those |
- scipy interp1d is now a legacy class and is not advised - if indices at start or end of array need to be interpolated, numpy interp will apply ZOH interpolation by default
|
Ok just pushed a commit, a couple notes: I just noticed that For a simple linear interpolation, |
larsoner
left a comment
There was a problem hiding this comment.
Just some minor stuff from me, looks good!
|
Thanks @scott-huberty ! |
* upstream/main: (26 commits) MAINT: Better fix for deprecation (mne-tools#11789) udpate doc for 11786 (mne-tools#11787) MAINT: Ignore warning in example (mne-tools#11781) Keeping event names when combining channel on epochs objects (mne-tools#11786) DOC: Fix incorrect docs for annotate_movement [ci skip] (mne-tools#11779) Refresh eegbci code and docstrings (mne-tools#11783) DOC: EEG eye-tracking alignment tutorial (mne-tools#11770) [MRG] By-pass set_annotations when plotting ICA sources (mne-tools#11766) add missing changelog from 11773 (mne-tools#11777) Fix eeglab.py, an error for read annotations in `RawEEGLab` (mne-tools#11773) [MRG] Use FIFF.FIFF_UNITM_NONE instead of 0 when adding a reference channel (mne-tools#11774) MAINT: Update for linkcheck [circle linkcheck] (mne-tools#11771) ENH: Interpolate blinks in eyetrack channels (mne-tools#11740) MAINT: Work around joblib bug (mne-tools#11765) Update manual install docs (mne-tools#11764) add logging message about which EOG channel used for blink detection (mne-tools#11757) DOC: Fix docs (mne-tools#11756) BUG: Fix bug with SNR calculation (mne-tools#11755) BUG: Fix bug with cHPI off (mne-tools#11754) Change color from annotation to red if name changes to "bad_" or "edge_" (mne-tools#11753) ...

Reference issue
Closes #11725
What does this implement/fix?
This implements a linear interpolation function in
mne.preprocessing.eyetracking, to interpolate missing values inpupilchannels during blinks.This time I wanted to get this PR up early / in a minimal working-state, so that devs have a change to review the foundation of the code, before we add more to it next week (see additional info below). I'm definitely interested in your feedback on the code design, if there are better (or more mne-like ) approaches you think I could take, I'm happy to hear your ideas🙂
Additional information
After discussing this function yesterday with @britta-wstnr , @mscheltienne , and @drammock , here are some ideas that were suggested (feel free to let me know if i missed anything):
remove
pytest.mark.xfailfrom the test for this module, after ENH, FIX: Make eyelink occular annotations "channel aware", and call blink annotations "BAD" #11746 is merged and confirm that tests passmake the interpolation channel specific. Right now, in the case of a binocular recording (2
pupilchannels), if there were a "wink" in the recording, bothpupilchannels would be interpolated.read_raw_eyelinkto add channel information in theblinkannotations.read_raw_eyelinkshould prepend blink annotations withBAD_, to be consistent with other mne functions. Then, this function would only interpolate over'BAD_blink'annotations by default. I'm not sure if there was a resolution on this matter, and I'm not sure yet how I feel about the idea.allow the user to specify the
annotationdescriptions that should be considered as blinks? something likeblink_annotations=['my_manual_blink'] ? we can give it a default value ofNone, which will use anyannotationdescription that starts with'blink'.also CC @larsoner
Minimally Working example
Here is the updated eye-tracking tutorial