<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sarthak</title>
    <description>The latest articles on DEV Community by sarthak (@sarthak_06679714d79dc1cf7).</description>
    <link>https://dev.to/sarthak_06679714d79dc1cf7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4074371%2Fa38f715c-d1ad-4f5b-a6ff-8c8bfd99eff8.png</url>
      <title>DEV Community: sarthak</title>
      <link>https://dev.to/sarthak_06679714d79dc1cf7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sarthak_06679714d79dc1cf7"/>
    <language>en</language>
    <item>
      <title>edfcore - Parsing EDF EEG files in TypeScript</title>
      <dc:creator>sarthak</dc:creator>
      <pubDate>Wed, 12 Aug 2026 08:26:59 +0000</pubDate>
      <link>https://dev.to/sarthak_06679714d79dc1cf7/edfcore-parsing-edf-eeg-files-in-typescript-4p0j</link>
      <guid>https://dev.to/sarthak_06679714d79dc1cf7/edfcore-parsing-edf-eeg-files-in-typescript-4p0j</guid>
      <description>&lt;p&gt;I built edfcore, a zero-dependency TypeScript library for reading EDF-family biosignal recordings — and what looked like a pretty straightforward binary format turned out to have a lot more personality than I expected.&lt;/p&gt;

&lt;p&gt;I wanted a clean way to work with EEG, ECG, and sleep-study recordings directly from JavaScript and TypeScript without having to route everything through Python first.&lt;/p&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;p&gt;npm install edfcore&lt;/p&gt;

&lt;p&gt;The goal is to make EDF data usable inside things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;browser-based EEG viewers&lt;/li&gt;
&lt;li&gt;Node.js processing pipelines&lt;/li&gt;
&lt;li&gt;Electron applications&lt;/li&gt;
&lt;li&gt;research platforms&lt;/li&gt;
&lt;li&gt;biosignal visualization tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The part I didn't expect was how many assumptions you can make about EDF that are completely wrong.&lt;/p&gt;

&lt;p&gt;There isn't one sampling rate&lt;/p&gt;

&lt;p&gt;An EDF file does not have one global sample rate.&lt;/p&gt;

&lt;p&gt;Every signal declares its own number of samples per data record, so the same recording can contain 256 Hz EEG beside a sensor updating once per second.&lt;/p&gt;

&lt;p&gt;That means any abstraction that treats the entire file as one uniform timeline has to repeat, interpolate, or otherwise change something.&lt;/p&gt;

&lt;p&gt;Annotations are signals&lt;/p&gt;

&lt;p&gt;EDF+ annotations aren't just sitting somewhere nicely separated as metadata.&lt;/p&gt;

&lt;p&gt;They're stored through a special signal channel.&lt;/p&gt;

&lt;p&gt;That means the same record structure can contain normal physiological samples for one signal and encoded event/timing information for another.&lt;/p&gt;

&lt;p&gt;BDF uses 24-bit samples&lt;/p&gt;

&lt;p&gt;BioSemi BDF makes things even more interesting because it stores signed 24-bit values.&lt;/p&gt;

&lt;p&gt;JavaScript gives you convenient integer readers for 16-bit and 32-bit values, but there is no getInt24().&lt;/p&gt;

&lt;p&gt;So those samples have to be reconstructed manually from three bytes and sign-extended correctly.&lt;/p&gt;

&lt;p&gt;The worst bugs look valid&lt;/p&gt;

&lt;p&gt;This ended up being the biggest lesson from building the parser.&lt;/p&gt;

&lt;p&gt;The annoying failure isn't:&lt;/p&gt;

&lt;p&gt;Error: cannot read file&lt;/p&gt;

&lt;p&gt;It's:&lt;/p&gt;

&lt;p&gt;Here are hundreds of thousands of perfectly normal-looking numbers.&lt;/p&gt;

&lt;p&gt;A parser can be slightly wrong and still generate a waveform that looks completely believable.&lt;/p&gt;

&lt;p&gt;That's why I spent a lot of time testing edge cases and comparing decoded results against existing EDF tooling.&lt;/p&gt;

&lt;p&gt;The result became edfcore.&lt;/p&gt;

&lt;p&gt;GitHub:&lt;br&gt;
&lt;a href="https://github.com/tayal-sarthak/edfcore" rel="noopener noreferrer"&gt;https://github.com/tayal-sarthak/edfcore&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Docs:&lt;br&gt;
&lt;a href="https://edfcore.vercel.app/" rel="noopener noreferrer"&gt;https://edfcore.vercel.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NPM:&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/edfcore" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/edfcore&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also built a companion CLI called edf2csv for people who just want an EDF/BDF recording converted into CSV:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/tayal-sarthak/edf2csv" rel="noopener noreferrer"&gt;https://github.com/tayal-sarthak/edf2csv&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both projects are MIT licensed.&lt;/p&gt;

&lt;p&gt;If you're building browser EEG tooling, Node-based research software, or anything else involving EDF files, I'd love to hear what you're working on.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>opensource</category>
      <category>softwaredevelopment</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
