New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raw.crop doesn't adjust onset of annotations for eyetracking data leading to interpolation errors #12408
Comments
Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴 |
from looking at the source code for i should say that cropping then adjusting the onset of each annotation will make it so that you can interpolate over the correct area of the signal, but there's then a big mismatch in the actual location of the blink:
the correct portions of the signal will now be interpolated, but when you actually plot the data you see that the annotations no longer line up with the truth of the signal. Something weird is going on for sure |
Thanks for the report! I think we need to account for mne-python/mne/preprocessing/eyetracking/_pupillometry.py Lines 75 to 100 in 65d826d
starting at line 89 above, something like:
After which, running your code above, should still interpolate the blinks as expected: |
neat! Thanks for the quick fix - would it be ok to change my also, possibly not the right place to mention this as it's less of an issue and more of a feature request - would it be possible to have this function return the non-interpolated, but still nanned signals? this is actually quite useful when you want to see how much data in a trial is missing (after epoching the raw data, it works well with |
@schekroud would you be up to submit a PR with the fix? If we get stuck somewhere (our change breaks existing tests, etc.) I'll be happy to help troubleshoot as well.
Like return a numpy array of the signals before interpolation? Sorry if I'm misunderstanding, but feel free to open up a new ticket if its something you want to discuss more! |
To fix this rather than any new code I think the solution is to use https://github.com/mne-tools/mne-python/blob/main/mne/annotations.py#L1049 Internally it uses
If this is all you need |
OK, using
|
@scott-huberty i'll submit the PR later on, sure
not quite. i'm talking about adding a channel during
i'll open a new issue with feature request to explain a bit more - but it is specifically quite useful for eyetracking to identify 'blinky' subjects that you may want to discard as you're interpolating large %s of data |
Sure, feel free. Maybe what we really need is a function to quantify how much of a given |
awesome!
if so, maybe we can just repurpose some of the code used for logging in mne-python/mne/preprocessing/artifact_detection.py Lines 600 to 613 in 65d826d
|
Description of the problem
specifically for eyetracking data (not sure about other types), the
raw.crop
method will trim the signal down appropriately, but no adjustment is made to the onset time of any annotations that remain in the data. this is particularly problematic when you usemne.preprocessing.eyetracking.interpolate_blinks
where it will just interpolate over random segments of the signali am not sure if this is an intended behaviour as I think, in the past, the
.crop
function has adjusted the onset time of events (before annotations were used). If i'm wrong, please send me away!Steps to reproduce
Link to data
No response
Expected results
it should interpolate the blinks (removing blink artefact)
Actual results
it interpolates exactly Xs after the blink, where X is the tmin applied in the
raw.crop
callAdditional information
Platform macOS-14.2.1-arm64-arm-64bit
Python 3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:37:07) [Clang 15.0.7 ]
Executable /Users/sammichekroud/anaconda3/envs/mne/bin/python
CPU arm (8 cores)
Memory 16.0 GB
Core
├☒ mne 1.6.0 (outdated, release 1.6.1 is available!)
├☑ numpy 1.26.2 (OpenBLAS 0.3.25 with 8 threads)
├☑ scipy 1.11.4
├☑ matplotlib 3.8.2 (backend=Qt5Agg)
├☑ pooch 1.8.0
└☑ jinja2 3.1.2
Numerical (optional)
├☑ sklearn 1.3.2
├☑ numba 0.58.1
├☑ nibabel 5.2.0
├☑ nilearn 0.10.2
├☑ dipy 1.7.0
├☑ openmeeg 2.5.7
├☑ pandas 2.1.4
└☐ unavailable cupy
Visualization (optional)
├☑ pyvista 0.43.1 (OpenGL 4.1 Metal - 88 via Apple M2)
├☑ pyvistaqt 0.11.0
├☑ vtk 9.2.6
├☑ qtpy 2.4.1 (PyQt5=5.15.2)
├☑ pyqtgraph 0.13.3
├☑ mne-qt-browser 0.6.1
├☑ ipywidgets 8.1.1
├☑ trame_client 2.14.1
├☑ trame_server 2.13.1
├☑ trame_vtk 2.6.3
├☑ trame_vuetify 2.3.1
└☐ unavailable ipympl
Ecosystem (optional)
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline
The text was updated successfully, but these errors were encountered: