dartedflib 0.1.0 copy "dartedflib: ^0.1.0" to clipboard
dartedflib: ^0.1.0 copied to clipboard

EDF lib for Dart (FFI bindings to edflib, a C-library created by Teuniz.net)

dartEDFLib #

Features #

A wrapper library around EDFLib v1.23 inspired by pyEDFlib v0.1.28 to read/write EDF+ files. The definition of the EDF/EDF+/BDF/BDF+ format can be found under edfplus.info.

This package uses dart:ffi to call libEDF's C APIs, which implies that libEDF must be bundled to or deployed with the host application.

Installation #

Make sure that you have installed/compiled EDFLib on your computer, and that it can be found by dylib. For example, you can set EDFLIB_PATH to the full path of the dynamic library (.dll/.so/.dylib), or to the folder where it can be found. (e.g. EDFLIB_PATH=C:\edflib\edflib.dll).

Add dartedflib to pubspec.yaml:

dependencies:
  dartedflib: ^0.1.0

Compiling EDFLib #

Install gcc on your computer.

# windows
gcc -Wall -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -shared edflib.c -o edflib.dll

# linux
gcc -Wall -Wextra -Wshadow -Wformat-nonliteral -Wformat-security -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -shared edflib.c -o libedflib.so

Usage #

import 'package:edflib/edflib.dart';

final writer = EdfWriter(fileName: filePath, numberOfChannels: 1);
try {
  final channelInfo = {
    'label': 'ECG1',
    'dimension': 'mV',
    'sample_frequency': measurement.deviceConfig!.ecgSampleRate!,
    'physical_max': 10.0,
    'physical_min': -10.0,
    'prefilter': '',
  };
  writer.setSignalHeaders(channelInfo);
  final data = List<num>.filled(500, 0.1);
  writer.writeSamples([data]);
} finally {
  // don't forget to close it!
  writer.close();
}

Additional information #

This package is currently developed by Praxa Sense.

Tests #

To run the unit tests via vs code, add the dynamic library to the root folder of this repo, because settings.json contains a reference to EDFLIB_PATH:

"dart.env": {
    "EDFLIB_PATH": "."
},

The .edf-files found in test/data are direct copies from pyedflib/tests/data.

Regenerating bindings.dart #

Make sure you have installed LLVM as described in ffigen.

In tasks.json there is a task to generate bindings.dart. It's important to notice that the edflib.h file in the root folder is taken for that. If you want to upgrade to a later version of EDFLib, replace edflib.h with a newer version and run the task.

1
likes
140
pub points
17%
popularity

Publisher

verified publisherpraxasense.com

EDF lib for Dart (FFI bindings to edflib, a C-library created by Teuniz.net)

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

dylib, ffi, version

More

Packages that depend on dartedflib