Speed up .edf export with edfio#12218
Conversation
|
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴 |
|
Conda+mamba checks fail since edfio is not on conda-forge yet, I'll work on that. |
Let me know if you need help, I did this for
|
|
Thank you for the simplified instructions! |
Pay attention. Allowing a measurement date outside the range 1985-01-01 to 2084-12-31 breaks backwards compatibility with EDF! |
|
Thank you for the heads up @Teuniz! edfio currently stores non-EDF-compatible startdates according to EDF+ specs in the "local recording identification" field and sets the EDF startdate field to "01.01.85". On read, it prefers the EDF+ startdate to the EDF startdate, but of course that only makes sense if no other software is used. Since EDFbrowser does not open files with such a mismatch, we will update edfio to refuse writing them :) |
Thanks! In an "ideal" world where all EDF software has been updated to EDF+, this shouldn't be necessary, |
|
Conda installs should work now, but I'll mark this as draft until the-siesta-group/edfio#5 is merged and released. |
|
note: once this is merged, we'll have to make adjustments in mne-bids: |
|
Just to be clear, even EDF+ mandates that the date range is between 1985–2084 (https://www.edfplus.info/specs/edfplus.html#additionalspecs). So regardless of EDFbrowser not opening it, this is non-standard and should therefore not be supported.
The spec also says: "After 2084, yy must be 'yy' and only item 4 of this paragraph defines the date." And this actually made my day 😄! |
|
Another comment: we don't actually require all dependencies to be on conda-forge, so installing via pip would have also worked. But I guess it doesn't hurt to have it available over there as well. |
|
There's a problem: edfio requires Python >= 3.9, but MNE currently still supports Python 3.8. This should be relatively easy to fix though by dropping support for Python 3.8. Actually, since we're already adopting SPECS, SPEC 0 says we should drop 3.8 and 3.9 (and support only 3.10, 3.11, and 3.12). |
|
Mind you our installers are often lagging behind by 1 Python release or so, because of the complicated mix of dependencies. Otherwise I'm all for cutting off things that are holding us back. |
|
Is there already a timeline for dropping Python 3.8 support? If not – or if the plan is not to do that anytime soon – it should be relatively simple to support 3.8 in edfio. Let me know if that would be your preferred solution! A few more things are fixed now:
|
|
We try to follow the scientific Python community standards for this and I think that means it's okay to drop 3.8 according to a quick look at https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table Let's push 1.6 out the door Monday or Tuesday (it's overdue) then drop 3.8 it while bumping dependency versions to 2-years-old. In the meantime you can ignore the "old" 3.8 CI |
SPEC0 is even more aggressive, but I'm fine with dropping only 3.8 after the 1.6 release. |
|
One more thing before I'm happy: exporting stimulus channels are not supported, right? For example, this test involves a |
|
Good idea! Added a warning and removed the stim channel from all but one test to avoid checking for that warning in unrelated tests. |
|
Great! Can you maybe remove this comment ( This test is a bit convoluted, feel free to clean up a bit if it makes sense. For example, there's actually a third export (the very last line), which I'm not sure what it actually tests (just a smoke test, but for what). And the test is called |
Because I'm curious, what's different about a stim channel that it cannot be saved in EDF+? |
Good question, there's no reason why this cannot be done. In fact, this would be a perfectly valid and useful thing to do, but for some reason MNE-Python has excluded stim channels. We did not want to mess with that in this PR, but we'll tackle it in another PR. I guess the main difference between "normal" (physiological) and stim channels is that the latter contain exact (integer) values, but this can be dealt with by setting the physical and digital minima/maxima appropriately. |
|
Done! |
|
Perfect, thanks! |
larsoner
left a comment
There was a problem hiding this comment.
Just minor stuff from me, happy to defer to @cbrnr's EDF expertise so if he's happy I think we can merge 👍
You'll want to merge in main shortly, though, because @cbrnr dropped 3.8 support in #12229 which is about to land, and I had to adjust the merge requirements to adapt (and merging main into your branch or rebasing will get you the correct CI names/runs to fulfill merge requirements)
mne/export/tests/test_export.py
Outdated
| def _pytest_mark_skipif_edfio_not_installed(): | ||
| return pytest.mark.skipif( | ||
| not _check_edfio_installed(strict=False), reason="edfio not installed" | ||
| ) |
There was a problem hiding this comment.
A simpler pattern is just to do:
edfio_mark = pytest.mark.skipif(...)
then each function can just be decorated with
@edfio_mark
def test...
doc/changes/devel.rst
Outdated
| Enhancements | ||
| ~~~~~~~~~~~~ | ||
| - None yet | ||
| - Speed up export to .edf in :func:`mne.export.export_raw` (:gh:`12218` by :newcontrib:`Florian Hofer`) |
There was a problem hiding this comment.
Should mention the switch from EDFlib-Python to edfio explicitly because people might need to pip install stuff to adjust
|
I agree with your comments, so let's wait until they are addressed. BTW, will this land in 1.6.1 (backported), or do we wait until 1.7? I'd prefer backporting. |
|
Done, thanks for the suggestions @larsoner! Backporting to 1.6.1 would require support for Python3.8 in edfio, right? |
True, I forgot. So I guess this will have to wait for v1.7 then (about 3 months). |
|
We should have na "Dependencies" section in the changelog to mention changes of dependencies. @larsoner WDYT? |
|
🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪 |
|
Thanks @hofaflo! |
Reference issue
Partially addresses #9883 (first and second issue), might supersede #12085
What does this implement/fix?
As suggested by @cbrnr here, edfio could be used to speed up the export to .edf files.
Additional information
physical_range="auto"(see here).test_rawarray_edfare removed, because