Skip to content

Enable exporting EDF files #9566

Closed

Description

@adam2392

Describe the new feature or enhancement

There are gists available for using PyEDFlib to write EDF files, and pyedflib seems to be relatively well maintained and used.

This proposal is to enable exporting EDF files, with a warning of course that there maybe loss of data in the info object. This would also enable mne-bids to perform writing EDF file datasets, which is a RECOMMENDED file format for storage of EEG/iEEG data.

In addition, this would enable writing to an open-access file format that is heavily interfaced in EEG industry. For example, Persyst, an EEG-analytics company can only read in manufacturing formats (natus/NK/etc.) and EDF. It cannot read fiff, BrainVision, or other open source formats.

Describe your proposed implementation

This would extend #9192 to add EDF file exporting. This would add an optional dependency with pyedflib (https://github.com/holgern/pyedflib).

Additional comments

Related issue in mne-bids: mne-tools/mne-bids#840

Activity

  1. larsoner commented on Jul 13, 2021

    @larsoner
    Member

    Sounds reasonable to me

  2. sappelhoff commented on Jul 14, 2021

    @sappelhoff
    Member

    Just so that this doesn't get lost, @Teuniz has chimed in in mne-tools/mne-bids#840 (comment) and suggested https://gitlab.com/Teuniz/EDFlib-Python as an alternative.

    Pros over PyEDFlib:

    • developed/maintained by the same person who develops EDFlib (which pyEDFlib uses)

    Cons:

    • no pypi package?
    • documentation/tests not very mature (no info on supported py versions, no CI, no API docs)
    • smaller user base (maybe hard to judge, I just see the GitLab stars)

    Finally, I think both packages have an edge over https://github.com/bids-standard/pyedf which is a separate package independent of EDFlib, ... but it never took off.

  3. cbrnr commented on Jul 14, 2021

    @cbrnr
    Contributor

    Thanks for the heads up @sappelhoff! IMO PyPI availability (pyEDFlib) trumps pure Python (EDFlib-Python) in this case, also because it is an optional dependency. Another issue might be the custom license, which is probably compatible with BSD, but I'm not sure. However, it shouldn't be too difficult to switch to a different EDF writer if the situation changes.

  4. agramfort commented on Jul 15, 2021

    @agramfort
    SponsorMember
  5. cbrnr commented on Jul 15, 2021

    @cbrnr
    Contributor

    If you count our own reader and Biosig there are even more. I completely agree that there should only be one well maintained EDF package in pure Python licensed under BSD/MIT.

    I just noticed that EDFlib-Python is advertised as licensed under BSD-3 (in contrast to the LICENSE file in the repo). So maybe that's a good starting point? How would you proceed @agramfort?

  6. Teuniz commented on Jul 15, 2021

    @Teuniz

    If you count our own reader and Biosig there are even more. I completely agree that there should only be one well maintained EDF package in pure Python licensed under BSD/MIT.

    I just noticed that EDFlib-Python is advertised as licensed under BSD-3 (in contrast to the LICENSE file in the repo).

    Correct me if I'm wrong but the license file at https://gitlab.com/Teuniz/EDFlib-Python/-/blob/master/LICENSE has the same text as here: https://opensource.org/licenses/BSD-3-Clause

  7. Teuniz commented on Jul 15, 2021

    @Teuniz

    honestly it's really a bummer that there is 3 EDF libraries in Python. Can we make these people collaborate so there is one good, well maintained and well tested library with a permissive BSD/MIT license?

    There can be many reasons why people sometimes don't want to collaborate.
    One example: how strict should an EDF-reader be in (dis)allowing to read from a not 100% compliant EDF file?
    EDFlib and EDFbrowser are very strict. Not everybody likes that.
    For me, the longterm future of the EDF format is more important than trying to please angry or disappointed users who have a database full of non-compliant files.

  8. cbrnr commented on Jul 15, 2021

    @cbrnr
    Contributor

    Correct me if I'm wrong but the license file at https://gitlab.com/Teuniz/EDFlib-Python/-/blob/master/LICENSE has the same text as here: https://opensource.org/licenses/BSD-3-Clause

    You're right, I didn't read the text but assumed because it is classified as "Other" that it is not any of the popular licenses (maybe it is possible to change this setting in GitLab somewhere?).

  9. cbrnr commented on Jul 15, 2021

    @cbrnr
    Contributor

    There can be many reasons why people sometimes don't want to collaborate.
    One example: how strict should an EDF-reader be in (dis)allowing to read from a not 100% compliant EDF file?
    EDFlib and EDFbrowser are very strict. Not everybody likes that.
    For me, the longterm future of the EDF format is more important than trying to please angry or disappointed users who have a database full of non-compliant files.

    Good example, we regularly deal with non-compliant files. I agree that it is important to enforce the file format, but often it's just tiny inconsistencies (such as different encodings) that are pretty easy to fix. This allows people to access their data, whereas the alternative is to have no data at all.

    I think a good solution is to enforce strict mode by default, but allow some minor deviations optionally.

    Regarding EDFlib-Python, would you be up for a PyPI release?

  10. agramfort commented on Jul 15, 2021

    @agramfort
    SponsorMember
  11. adam2392 commented on Jul 15, 2021

    @adam2392
    MemberAuthor

    Regarding EDFlib-Python, would you be up for a PyPI release?

    +1 for using @Teuniz 's "strict" EDFlib-Python library. I'd rather have an EDF file that can be read by EDFBrowser, then just "EDF by name" and can only be read by MNE/EEGlab functions.

    If there is a pypi release, we can then add that as an optional dependency in export_edf?

  12. cbrnr commented on Jul 15, 2021

    @cbrnr
    Contributor

    An EDF writer should definitely be super strict. My comments on relaxing some restrictions a little apply only to a reader.

  13. Teuniz commented on Jul 16, 2021

    @Teuniz

    An EDF writer should definitely be super strict. My comments on relaxing some restrictions a little apply only to a reader.

    That's not going to happen. EDFlib is finished and offered "as is". Consider it an LTS release.
    Any bugs wiil be fixed ofcourse. New function calls will be taken into consideration if it makes sense.
    API breakage is not going to happen though.
    Ofcourse, there's always the option to clone & fork and turn it into a "community project" but my support will be limited
    to the vanilla EDFlib.

  14. cbrnr commented on Jul 16, 2021

    @cbrnr
    Contributor

    I think we were mostly talking about the writer component, because we already have our own reader which is not that strict.

  15. Teuniz commented on Jul 16, 2021

    @Teuniz

    Understood and no problem. The Python version of EDFlib is split into a reader and a writer part
    (they are different files) and you can simply grab the writer only and don't bother with the reader if you wish.

  16. adam2392 commented on Jul 16, 2021

    @adam2392
    MemberAuthor

    Awesome!

    What would be the next best course of action here if EDFlib isn't pypi released?

  17. drammock commented on Jul 16, 2021

    @drammock
    Member

    @Teuniz would you be open to doing a PyPi release of python EDFlib? One of us could help out with the changes needed for packaging, if that makes a difference. If not, I think our only option for using EDFlib is incoporating the writer into our externals/ (which we tend to be hesitant to add things to)

  18. Teuniz commented on Jul 16, 2021

    @Teuniz

    @Teuniz would you be open to doing a PyPi release of python EDFlib? One of us could help out with the changes needed for packaging, if that makes a difference. If not, I think our only option for using EDFlib is incoporating the writer into our externals/ (which we tend to be hesitant to add things to)

    I'll look into it, I have never done it before but I have a colleague with lots of Python experience.
    It's just that we are entering the holiday period here, so it will take some time.

  19. adam2392 commented on Aug 4, 2021

    @adam2392
    MemberAuthor

    I took a stab at sketching out the export functionality. The barebones works (with some details not matching up).

    Just a friendly ping to see if there was any update on getting a PyPi release? I can help with it if needed?

  20. Teuniz commented on Aug 5, 2021

    @Teuniz

    Just a friendly ping to see if there was any update on getting a PyPi release?

    It's done, you can find it here: https://pypi.org/project/EDFlib-Python/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions