Skip to content

Add .nwb as supported format for EEG #2111

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yarikoptic
Copy link
Collaborator

NWB is BRAIN Initiative supported, and open data standard https://neurodatawithoutborders.github.io/ .

The main motivation here is to support joint iEEG and EEG datasets for EMBER archive project. Quick google can show that there is a good number of studies which have conjoint EEG and iEEG. Since .nwb is supported for iEEG, it makes only sense to add support for it in EEG modality as well.

There is a good number of .nwb "specific" tools in the ecosystem, with a notable mention of https://neurosift.app which allows "smart" client-side (in browser) access to remote .nwb files for exploration.

It seems that there is also growing number of toolkits in EEG world which support NWB. E.g., EEGLAB already input support for NWB: https://eeglab.org/plugins/NWB-io/ so data would be accessible in this popular toolkit.

Added listing of NWB into EEG formats table + harmonize (change URL also) in iEEG section

Attn @bids-standard/raw-electrophys-eeg and @dorahermes

NWB is BRAIN Initiative supported, and open data standard
https://neurodatawithoutborders.github.io/ .

The main motivation here is to support joint iEEG and EEG datasets for
EMBER archive project.  Quick google can show that there is a good number of
studies which have conjoint EEG and iEEG.  Since .nwb is supported for iEEG, it
makes only sense to add support for it in EEG modality as well.

There is a good number of .nwb "specific" tools in the ecosystem, with a
notable mention of https://neurosift.app which allows "smart" client-side (in
browser) access to remote .nwb files for exploration.

It seems that there is also growing number of toolkits in EEG world which
support NWB.  E.g., EEGLAB already input support for NWB:
https://eeglab.org/plugins/NWB-io/ so data would be accessible in this popular
toolkit.

Added listing of NWB into EEG formats table + harmonize (change URL also)
in iEEG section
@yarikoptic yarikoptic added enhancement New feature or request iEEG EEG Electroencephalography labels May 6, 2025
@effigies effigies added this to the 1.10.1 milestone May 6, 2025
Copy link
Collaborator

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support this on the grounds of consistency across modalities and working with other standards.

That said, as someone who wouldn't be tasked with implementing this, I would like to see support from EEG software groups, e.g., MNE-Python (@larsoner), FieldTrip (@robertoostenveld), etc.

@robertoostenveld
Copy link
Collaborator

In theory FieldTrip has support for NWB as per fieldtrip/fieldtrip#1419, but in practice it does not work. I just tried it (again, I recall having struggled with it before) and I cannot read any of the NWB test files that I have.

From the FieldTrip pull request:

It is assumed that the user is familiar with the basics of MatNWB (Github MatNWB) and the user's system is in a state that would also allow loading the data using MatNWB (MatNWB must be in the path, generateCore must have been run, the correct schema must be installed, see NWB schemas).

Those assumptions are apparently not met by me and/or my computer.

@robertoostenveld
Copy link
Collaborator

Zooming out: I am not yet convinced by the arguments to add NWB to the list of EEG formats. I don't think it is sufficient if someone happens to have data in some format, and if that format is open (whatever loose definition applies for that), that we then extend the BIDS standard with that format. Proliferation of formats has been argued against in many of the BEPs (most recently AFAIK in the EMG BEP).

Did we not have some text somewhere that stated the considerations for extending the list of file formats? ... oh, I found it: it is not under EEG (or elsewhere) but under the iEEG section:

Future versions of BIDS may extend this list of supported file formats. File formats for future consideration MUST have open access documentation, MUST have open source implementation for both reading and writing in at least two programming languages and SHOULD be widely supported in multiple software packages. Other formats that may be considered in the future should have a clear added advantage over the existing formats and should have wide adoption in the BIDS community.

The critical aspects here are "clear added advantage over the existing formats" and "wide adoption" (which I think here refers to the EEG field).

PS I do wish we did have a single standard file format that we could settle on. Perhaps that is something to plan for in BIDS 2.0, where the people that care about a modality get locked up in conclave and are only allowed out when white smoke signals that they have agreed upon a single file format.

@dorahermes
Copy link
Member

This discussion is related to guidelines for new formats in issue #2055
Point 5 is important: "The format must meet the technical requirements of neuroscientific workflows". In my interpretation, this means that developers of a format should make sure that common software packages should be able to read and write these data.

On the workflow side for iEEG, data are often collected concurrently with EEG, MEG, ECG etc and everything is collected on one amplifier and stored in one format. IMHO this does not mean that iEEG formats should propagate to such other formats.

@yarikoptic
Copy link
Collaborator Author

It is assumed that the user is familiar with the basics of MatNWB (Github MatNWB) and the user's system is in a state that would also allow loading the data using MatNWB (MatNWB must be in the path, generateCore must have been run, the correct schema must be installed, see NWB schemas).

Those assumptions are apparently not met by me and/or my computer.

That PR is from half a decade ago, or are these observations current? I believe such assumptions were addressed or at least relaxed since then, e.g. see

FWIW, as for "one file format to rule them all" insofar I know only two overarching standards of such kind: DICOM and NWB ;-)
My concern here would indeed be NWB's adoption particularly for EEG data (it is the standard for microelectrode neurophysiology data AFAIK, hence would be the main format for BEP032). May be @rly and @oruebel could comment on, point to prominent examples?

@hoechenberger
Copy link
Collaborator

I may be a bit naive, but I'm unable to find an official specification of the file format? I can only seem to find implementations, but not an authoritative spec? Can someone help me out here please?

@cbrnr
Copy link

cbrnr commented May 8, 2025

I 100% agree with @robertoostenveld. As a maintainer of MNE-Python, I don't think anyone should spend time implementing support unless (1) it is absolutely clear what the advantage of NWB is over other formats, and (2) it can be demonstrated that the format has been widely adopted.

@effigies
Copy link
Collaborator

effigies commented May 8, 2025

@hoechenberger https://nwb-schema.readthedocs.io/en/latest/format_description.html

@hoechenberger
Copy link
Collaborator

Thank you!

@bids-standard bids-standard deleted a comment from hoechenberger May 8, 2025
@robertoostenveld
Copy link
Collaborator

Interesting! I now see that it is based on HDF5 as the container file format and that NWB basically defines the schema that is used within the HDF5 container. As such it is actually quite similar to SNIRF for NIRS.

@yarikoptic
Copy link
Collaborator Author

yarikoptic commented May 8, 2025

Correct, it is primarily a schema on top of HDF5 (edit: pynwb and NWB extensions can provide additional convenience interfaces beyond schema driven). Moreover, due to inherent limitations of a single binary file approach, work is in progress to implement NWB on top of Zarr: this is where it is going on - https://github.com/hdmf-dev/hdmf-zarr (HDMF is core library, agnostic of NWB schema).
Related to that, used by @magland's mentioned above neurosift , he implemented https://github.com/NeurodataWithoutBorders/lindi which exposes internal to NWB schema as a json, which is actually a valid zarr archive. See e.g. https://lindi.neurosift.org/dandi/dandisets/000458/assets/6ab37be4-adfe-4bea-a031-eb1a2b0782a8/nwb.lindi.json which is a lindi view of a nwb with EEG and behavioral data which could also be navigated at https://neurosift.app/nwb?url=https://api.dandiarchive.org/api/assets/6ab37be4-adfe-4bea-a031-eb1a2b0782a8/download/&dandisetId=000458&dandisetVersion=0.230317.0039 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EEG Electroencephalography enhancement New feature or request iEEG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants