EDF writer
Opened this issue ยท 3 comments
So I have been delving into this edf conversion topic. What I have found is the following:
- edf conversion is possible in python with the main library people keep using being pyedflib. There are some others like python-edf which actually was the basis for pyedflib
- this pyedflib is dependent on the edflib C++ library
- pyedflib it is not supported in mne, since the aforementioned library needs cython. MNE avoids this since packaging compiled code is too much work
- Because of this what exist are some codes that take mne objects and exports it to EDF, these codes are outside of mne, for example:
Robert Oostenveld and Phillip Alday did a pure python edf writer: pyedf . It is in python2 but has a branch on python3 and also the following repo https://github.com/bsandeepan95/pyedf . It also seems slower (expected) than pyedflib (bids-standard/pyedf#6)
Apparently pyedf has not been integrated to mne because it adds maintainance overhead while making relatively little difference in usability
Why is this important?
Our design has mne-bids as the bids writer, that is, we just infer the necessary arguments and the "CONVERT THEM" module does the job with mne-bids inside. So as it is now, we are constrained by what mne-bids accepts as outputs:
format : 'auto' | 'BrainVision' | 'FIF' Controls the file format of the data after BIDS conversion. If
'auto'
, MNE-BIDS will attempt to convert the input data to BIDS without a change of the original file format. A conversion to a different file format (BrainVision, or FIF) will only take place when the original file format lacks some necessary features. When a str is passed, a conversion can be forced to the BrainVision format for EEG, or the FIF format for MEG data.
So we have some options:
- Suggest edf conversion (and do a PR) in mne-bids being the main argument that it is one of the recommended formats of bids. I guess this would be done with pyedf since it does not need compiled code.
- Convert the output of mne-bids to edf by a postprocess code.
- Don't support edf for the moment.
@stebo85 @civier @TomEmotion What do you think?
Thanks @yjmantilla for investigating it. Very surprising given that edf is one of two recommended formats for BIDS.
I originally suggested edf over BrainVision because it is an open standard (see @TomEmotion comment in our meeting), but for the GSoC project, maybe we should only focus on BrainVision as the output format. It is still one of the recommended BIDS formats, so I don't see an issue with that. Adding edf support can be a longer-term goal, and ideally done by incorporating edf support into MNEbids.
Any thoughts mentors? Dave? @stebo85 @TomEmotion @aswinnarayanan @DavidjWhite33
Starting with BrainVision makes sense and later we could investigate how to best get things converted into EDF.
I think these problems should be solved upstream (in MNE?), but we should help if we have the time towards the end of the project:
pyedflib - I had a similar problem with cython and found a good workaround by compiling the cython code before execution on the target system -> by this we avoided distributing precompiled binaries that wouldn't be optimized for the hardware at hand (https://github.com/NeuroDesk/caid/blob/master/recipes/qsmxtbase/setup.py). The other option is to compile it with "-march=x86-64" and this will run on almost all CPUs (but slower than with specific instruction sets) -> https://github.com/NeuroDesk/caid/blob/master/recipes/tgvqsm/setup.py
pyedf - looks good, too - I wouldn't be too worried about the speed to start with - worth a try?
Cheers
Steffen
So for now, I guess the conclusion is to use brainvision. Later if we have got time we can try to address the issue in MNE-BIDS through pyedf (why MNE-BIDS? I don't think the matter is relevant enough for MNE as a whole).