Skip to content
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

EyeTracking / New Step? #949

Open
behinger opened this issue May 14, 2024 · 4 comments
Open

EyeTracking / New Step? #949

behinger opened this issue May 14, 2024 · 4 comments

Comments

@behinger
Copy link

behinger commented May 14, 2024

Hi!
we have ET/EEG combined data and we would love to use mne-bids-pipeline. For this we would want to follow this mne-tutorial which uses read_raw_eyelink + some synchronisation steps.

We couldnt figure out if there is a modular "add_step" guide somewhere, that allows to run custom code (which would be super helpful btw!). We found that the ICLabel PR #812 works by modifying the code of the preproc-ic-step. O.c. we could "hack" a solution by hijacking any other step to synchronize the EEG/ET data - but if there is an "official" way to include new steps (maybe user-defined, maybe for PRs) we would appreciate some pointers :-)

Apologies if this is documented somewhere and we missed it. We'd be happy to contribute such a step to the pipeline, even though we acknowledge it is a bit on the rare side to need it ;-)

Cheers, @jschepers @behinger

Copy link

welcome bot commented May 14, 2024

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

@drammock
Copy link
Member

adding custom steps has definitely come up before (e.g. in #303) and IIRC it's status is planned-but-not-yet-implemented. @larsoner or @hoechenberger will probably know better how far off we are from supporting it... But I think for now it boils down to "run the pipeline up to the step just before your custom code, run your custom code on the intermediate files, then resume the pipeline with the output of your custom code". Obviously some care is needed with filenames/paths, etc.

That said: support for combined EEG / ET analysis in an "official" way seems like a nice feature (maybe rare, but certainly not one-off). So another option is to incorporate what you come up with into the package itself.

@larsoner
Copy link
Member

Hmm... aligning the EEG and eye tracking data is probably going to be experiment-dependent, involving the alignment/registration/fixing of shared triggers or something similar. If there's any way you can do this before the BIDS step -- and for example concatenate the aligned data into a single FIF -- that would make use in MNE-BIDS-Pipeline easier. Maybe it's not really in the spirit of BIDS... but I did it recently for MEG+EEG data recorded simultaneously on different systems and it wasn't too bad.

As far as custom steps go, can you look at #924 (comment) and see if you think there's some way you could leverage such an API to do what you need?

@behinger
Copy link
Author

yes, in principle the alignment could be made before and the _events.tsv adjusted manually, Nevertheless, it would be nice to have a specific step for this. There are MNE functions to help with the synchronisation via:

mne.preprocessing.realign_raw(
    raw_et, raw_eeg, [et_flash_times], [eeg_flash_times], verbose="error"
)

What MNE practically does is filter the ET-annotations/events and the EEG-annotation/events for the common trigger, and regress that times (I assume ;-)). If the events can be specified in the config, then this should be relatively general.

The callback/hook you mention in 924 would work indeed. I think related but a different issue, I will investigate how to "temporarily" filter something for ICA and then apply the weights to the original data.

For now, what I will do is to define my own step or manually hook it into an existing step in the library. This then later could be converted to a manual hook, or as a PR however you wish.

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

No branches or pull requests

3 participants