rob-luke / Neuroimaging.jl

Neuroimaging in Julia
https://rob-luke.github.io/Neuroimaging.jl
BSD 3-Clause "New" or "Revised" License
48 stars 11 forks source link

Read EDF file format #16

Open abcsds opened 7 years ago

abcsds commented 7 years ago

Very similar to BDF files, EDF is the standard format of biosignals for many EEG amplifiers, including the cheapest in the market: Emotiv Epoch, Emotiv Insight, and OpenBCI. Adding support to this format would allow a bigger community to use and support the project. The description of the format can be found here, and an attempt at reading EDF from julia can be found here (although it seems like it's only some pasted python code)

From the google julia-users group I've found this code:

function load_edf(filename::String)

  header = Dict{ASCIIString,Any}()

  open(filename,"r") do fd
    version =  bytestring( read(fd, Uint8, 8) )
    header["version"] = version

    localPatientId =  bytestring( read(fd, Uint8, 80) )
    header["version"] = localPatientId

    ...

    # here the data would be read
  end
  return data, header
end

The conversation also points to @codles BDF.jl, but when trying to read an EDF with EEG.jl the following error appears:

WARNING:root:File type edf is unknown

I would love to help creating the functionality, but I'm still not very well acquainted with the library. If you can point me in the right direction I'll do my best to create it.

rob-luke commented 7 years ago

Thanks for the suggestion. Currently I use BDF.jl for reading data. I believe Sam has started working on EDF files in that package in a separate branch.

If EDF reading in BDF.jl is stable I will be happy to add support for it in this package. I have been meaning to overhaul the reading functions. Actually the whole package is ready for a refactor now that test coverage is high and a stable version was tagged on julia v0.4.

If you want to help then I would suggest reviewing @sam81 EDF reading code. Make sure it works with your files and report back to that package. Once the functionality is in master I will add it here. Unless @sam81 has other suggestions?

sam81 commented 7 years ago

@abcsds contributions to the EDF functionality in BDF.jl would be very welcome. The basic reading functionality is already in place but it has received very little testing and does not currently implement the full EDF/EDF+ specifications. I'll have very limited time and limited internet connectivity in the next month, but I'll try to answer any possible queries as well as I can. A good place to start to get familiar with the library is to look at the BDF specifications which are explained in a very clear way on the Biosemi website, and see how they are implemented in BDF.jl.

wherrera10 commented 6 years ago

Happy New Year! Is the EEG.jl module still being updated? I have finally over the holidays had time to look at specs long enough to put together a module that reads and writes EDF+ and BDF+ files.

This is not a fork of EEG,jl. It does not handle triggers like EEG.jl does, since it is for processing EEG data more than for evoked potentials. I suppose you could use it to pull channels and annotations out for further use, though. It is still early alpha and not registered as an official Pkg. If you think you could use it in some way, have a look:

https://github.com/wherrera10/EDFPlus

rob-luke commented 6 years ago

Gday @wherrera10 ,

I'm just about to dive back in to this project so appreciate the update on your package, it looks great.

I plan to give EEG.jl an overhaul with julia 1.0. And am very keen to add EDF support.

Over the next year I am planning to add support for more than just evoked potentials and support for other signals such as MEG, FNIRS, spike trains, etc. I'm considering rolling this in to a new package Electrophysiology.jl, that's been on hold for a while. However, I will maintain this EEG.jl in the meantime and provide an easy transition when appropriate.

wherrera10 commented 6 years ago

Hello Robert,

Thanks for the notes! I like the idea of expanding the package once things are tested against the 1,.0 release. I am moving slowly toward a hardware and software package for automation of certain kinds of intensive care monitoring, but that is as yet far away. I think Julia1.0 will arrive waaay before then.

Best wishes,

--Bill

On Wed, Jan 10, 2018 at 2:12 PM, Robert Luke notifications@github.com wrote:

Gday @wherrera10 https://github.com/wherrera10 ,

I'm just about to dive back in to this project so appreciate the update on your package, it looks great.

I plan to give EEG.jl an overhaul with julia 1.0. And am very keen to add EDF support.

Over the next year I am planning to add support for more than just evoked potentials and support for other signals such as MEG, FNIRS, spike trains, etc. I'm considering rolling this in to a new package Electrophysiology.jl https://github.com/codles/Electrophysiology.jl, that's been on hold for a while. However, I will maintain this EEG.jl in the meantime and provide an easy transition when appropriate.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/codles/EEG.jl/issues/16#issuecomment-356781324, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ7lfIHLLxG2HjhvlVYenOcRSHw8oY1Xks5tJVH6gaJpZM4JnJOb .

stefanches7 commented 4 years ago

Hello @rob-luke and others,

Beacon biosignals have rolled out a package for reading EDF in the meantime (https://github.com/beacon-biosignals/EDF.jl). Works like a charm! Maybe it could be integrated or referenced in the current package.

Marco-Congedo commented 4 years ago

That's great! To all: the neuroimaging community is converging toward the BIDS standard for sharing neuroimaging data. With EDF IO support it is possible to support the BIDS standard fr EEG/MEG. Is there any plan on doing this?

Tokazama commented 4 years ago

Note that EDF is a supported storage format within the BIDS standard. Therefore, the only thing really stopping us from properly supporting the BIDS standard at this point is a standard approach to file management as described by BIDS. I believe BIDSTools.jl was made for this sort of thing.

That being said, standard file management is of little benefit to anyone if once we read the data into Julia it all uses different structures and APIs. This was one of the primary motivators for starting NeuroCore.jl. The last couple weeks I've been trying to get some other parts of the Julia ecosystem in place to make another major PR to NeuroCore.jl. At which point it will hopefully be ready for incorporation into the general registry for people to play around with.

wherrera10 commented 4 years ago

If there is a need to look at the details for the EEG extension to BIDS, it is here: https://www.nature.com/articles/s41597-019-0104-8

In the future, it's possible some journals will ask for open data to be archived in such a format, though I know of none that do now. As Zachary said, working with the data would generally require unpackaging it from such a storage form.

On Sat, Jan 11, 2020 at 2:52 AM Zachary P Christensen < notifications@github.com> wrote:

Note that EDF is a supported storage format within the BIDS standard. Therefore, the only thing really stopping us from properly supporting the BIDS standard at this point is a standard approach to file management as described by BIDS. I believe BIDSTools.jl https://github.com/TRIImaging/BIDSTools.jl was made for this sort of thing.

That being said, standard file management is of little benefit to anyone if once we read the data into Julia it all uses different structures and APIs. This was one of the primary motivators for starting NeuroCore.jl https://github.com/JuliaNeuroscience/NeuroCore.jl. The last couple weeks I've been trying to get some other parts of the Julia ecosystem in place to make another major PR to NeuroCore.jl. At which point it will hopefully be ready for incorporation into the general registry for people to play around with.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rob-luke/EEG.jl/issues/16?email_source=notifications&email_token=ACPOK7DBEUARBNU4QPFG5HDQ5G6ILA5CNFSM4CM4SON2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIWBJXQ#issuecomment-573314270, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPOK7EGJZ7XUI3PO2DR7MDQ5G6ILANCNFSM4CM4SONQ .