Coder Social home page Coder Social logo

edfdecoder's Introduction

npm install --save edfdecoder

This project is a EDF file decoder in Javascript, for browser and NodeJS. Due to the lack of standard format in the world of electroencephalogram (EEG), EDF progressively took that seat, even though it is limited and far from perfect. Thanks to its simple specification, the EDF format is also used in many other bio-medical fields, not only EEG.

It is important to mention that two format are labeled EDF:

  • The regular EDF format (link)
  • The extended EDF+ (link)

This parser is NOT compatible with EDF+.

[DOCUMENTATION]
[DEMO READING] [DEMO PLOTTING]

Get started

To run the EdfDecoder you need a .edf file. Then, you have to run a procedure to get the file content as an ArrayBuffer. If you need some help on that, you can see the file examples/browser.html.

Then, create an instance of EdfDecoder and feed it with the buffer from the file:

// say you have a buffer from an edf file named fileBuffer

var decoder = new edfdecoder.EdfDecoder();
decoder.setInput( buff );
decoder.decode();
var myEdf = decoder.getOutput();

The EdfDecoder.getOutput() method returns an instance of Edf (link to doc).
This Edf object contains all the data from the edf file plus some helper function to query all these data.

Use an Edf object

The header of edf file contains metadata that are accessible using helper functions in edfdecoder, you can see the list of methods here.

// Get the number of signals, usually it is equivalent to the number of sensors
var numberOfSignals = myEdf.getNumberOfSignals();

// get the number of record
// note that each signal can have multiple records. A classic case is to have 1-second-long records
var numberOfRecords = myEdf.getNumberOfRecords();

// Get the signal, but you need to specify which signal and the index of the record
var signalIndex = 0;
var recordIndex = 0;
var aSignal = myEdf.getPhysicalSignal( signalIndex, recordIndex );

// It can be convenient to concatenate records from a same signal
// for example to get a signal that is longer than 1sec
var firstRecord = 8;
var numberOfRecords = 15;
var aLongerSignal = myEdf.getPhysicalSignalConcatRecords( signalIndex, firstRecord, numberOfRecords );

edfdecoder's People

Contributors

jonathanlurie avatar devwal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.