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

read xdf files (primitive) #10420

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

read xdf files (primitive) #10420

wants to merge 4 commits into from

Conversation

lokinou
Copy link

@lokinou lokinou commented Mar 7, 2022

Hi, I have implemented a code to read xdf files and I'd like to share it with my colleagues.
I assumed this would be the right place to do it

What does this implement/fix?

adds read xdf file to raw

Additional information

Can't figure out how to write the tests but I provided a sample.
I could provide a smaller test sample and redo the git history if size (32MB) is excessive

@welcome
Copy link

welcome bot commented Mar 7, 2022

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

@agramfort
Copy link
Member

ping @cbrnr

@cbrnr
Copy link
Contributor

cbrnr commented Mar 7, 2022

Hi @lokinou, this is awesome! However, in the meantime we have already a working implementation which also supports multiple streams simultaneously (via resampling) in MNELAB. Would you mind checking out our implementation and if you have any comments or suggestions (e.g. some feature that you have implemented that we don't) let us know?

We could also discuss moving the reader from MNELAB to MNE, so far we have not reached a conclusion if this is what we want (given that XDF usually contains other non-M/EEG streams that MNE cannot process).

@agramfort
Copy link
Member

agramfort commented Mar 7, 2022 via email

@cbrnr
Copy link
Contributor

cbrnr commented Mar 7, 2022

what I remember is that we need to handle the fact that xdf can have irregular sampling

I convert these to annotations.

and different sampling rates between streams

This works now by resampling.

@lokinou
Copy link
Author

lokinou commented Mar 7, 2022

@cbrnr Hello, I must admit I realized a few hours after that it's a shameless copy paste from your code from MNELab with a few flexibility additions (find by stream name and stream type). I must apologise for that 😅, I had a feeling function header wasn't my style but I forgot where it came from.

I think the dicussion you're having is above my level, but from what i see the code realigns markers with the first EEG timestamp:
|first--------------------- eeg stream--------------| Regular
_______|first---------------- marker stream----| Irregular
|----------| <- correction handled

@agramfort
Copy link
Member

what do you think @cbrnr is pyxdf stable/maintained enough to add a read_raw_xdf in mne?

@cbrnr
Copy link
Contributor

cbrnr commented Mar 8, 2022

what do you think @cbrnr is pyxdf stable/maintained enough to add a read_raw_xdf in mne?

Yes, but I don't think this is super urgent. If people want to read XDF now, they can do from mnelab.io import read_raw and then read the file. If we want to move that to MNE, we should definitely do it after 1.0.

@agramfort
Copy link
Member

agramfort commented Mar 8, 2022 via email

@lokinou
Copy link
Author

lokinou commented Mar 8, 2022

Yes, but I don't think this is super urgent. If people want to read XDF now, they can do from mnelab.io import read_raw and then read the file. If we want to move that to MNE, we should definitely do it after 1.0.

The reason I made this solution in the first place is that the from mnelab.io.xdf import read_raw_xdf required me to provide a streamid, meaning that I had to read the xdf files by hand using pyxdf and look at what every stream corresponds to before using the function. This is not a user friendly solution for someone that wants to try python-mne examples with a xdf file.

@MaxMascini MaxMascini mentioned this pull request Nov 22, 2024
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.

3 participants