xdf 0.2.0
xdf: ^0.2.0 copied to clipboard
Read and write XDF (Extensible Data Format) recordings.
xdf #
xdf reads and writes
XDF (Extensible Data
Format) recordings, the file format of LabRecorder and Lab Streaming Layer.
It is pure Dart and runs on all platforms, including the web.
Clock synchronisation, jitter removal and effective sampling rates follow
the algorithms and defaults of pyxdf. The results are tested against pyxdf
1.17.5 on the example files of xdf-modules (see test/fixtures).
To inspect an XDF file without writing code, it can be opened in LSL Viewer, which is built on this package. In the web app the file is read locally in the browser.
Installation #
dart pub add xdf
Usage #
loadXdf reads a whole file into memory and corresponds to load_xdf in
pyxdf:
import 'dart:io';
import 'package:xdf/xdf.dart';
void main() {
final rec = loadXdf(File('session.xdf').readAsBytesSync());
for (final s in rec.streams) {
print('${s.info.name}: ${s.length} samples at ${s.effectiveRate} Hz');
}
}
The package has four entry points:
| Entry point | Purpose |
|---|---|
loadXdf(bytes) |
A whole file in memory, with synchronised clocks (robust fit, detection of clock resets), jitter removal and effective rates |
XdfFile.open(ByteSource) |
Files that are too large to load at once |
XdfWriter |
Writing a file as data arrives (headers, samples, clock offsets, boundaries, footers), for example to record LSL streams |
readChunks, readSamples |
The raw chunks of a file |
Large files #
XdfFile.open indexes a file in one pass and reads it on demand. For each
regularly sampled stream it builds summary pyramids, from
signal_core, so that overviews,
zooming and filtered windows are fast. Markers and irregular streams are
kept in memory. A stream without breaks receives exactly the time stamps
that pyxdf assigns.