edfcore: Reading EDF and BDF EEG recordings directly in TypeScript
I've been working with EDF recordings for EEG and neuroscience projects and kept running into the same problem: most mature EDF tooling assumes Python or native software, while there are comparatively few options for developers building directly in JavaScript or TypeScript.
So I built edfcore, an open-source, zero-dependency TypeScript library for reading EDF-family biosignal recordings directly in browser and Node.js applications.
Install:
npm install edfcore
It supports EDF, EDF+, BDF, and BDF+ and exposes signal samples, channel metadata, sampling information, physical units, annotations, and recording timelines programmatically.
A few parts of the format ended up being much stranger than I expected.
EDF doesn't actually have one global sampling rate. Every signal can contain a different number of samples per data record, meaning EEG at 256 Hz can coexist with a much slower physiological channel in the same recording.
EDF+ annotations are also encoded through a special signal channel rather than being ordinary metadata.
BioSemi BDF adds another issue: its samples are signed 24-bit integers. JavaScript provides convenient readers for 16-bit and 32-bit integers, but not 24-bit values, so those samples have to be reconstructed manually.
The reason I separated edfcore into its own package is that I don't want every browser EEG viewer, BCI application, or Node-based research tool to have to implement these details independently.
GitHub:
https://github.com/tayal-sarthak/edfcore
Documentation:
https://edfcore.vercel.app/
npm:
https://www.npmjs.com/package/edfcore
I also maintain edf2csv, a separate command-line tool for researchers who simply want EDF/BDF recordings converted into accessible CSV files:
https://github.com/tayal-sarthak/edf2csv
Both projects are MIT licensed.
I'd especially love feedback from anyone building browser-based EEG/BCI tools or anyone with unusual EDF/BDF recordings that would be useful for testing.
Comments
Sarthak,
Thanks for making this available to the community, via our Forum.
You can also make a post on the 'Community' section of the OpenBCI website. Instructions:
https://openbci.com/community/
https://docs.openbci.com/GettingStarted/Community/Community/
Regards, William