xdf library
XDF (Extensible Data Format), the file format of LabRecorder and the Lab Streaming Layer.
- loadXdf reads a whole file into memory, like pyxdf's
load_xdf(clock synchronisation, clock reset handling and jitter removal with pyxdf's algorithms and defaults). - readChunks and readSamples give the raw chunks.
Pure Dart; works on all platforms, including the web.
Classes
- LSLChannel
-
One channel, as a stream's metadata describes it
(
desc/channels/channel). - XdfBytesWriter
- Writes little-endian values.
- XdfChunk
- One chunk of an XDF file: its tag and content (after the tag), which starts at offset in the file.
- XdfClockOffset
- A clock offset measurement: at time on the stream's own clock, that clock was value seconds behind the recorder's (add it to the stream's time stamps to get the recorder's time).
- XdfEvents
- Samples of an irregular stream (e.g. markers), in memory.
- XdfFile
- Random access to a large XDF recording without loading it into memory.
- XdfFileOptions
- Settings for XdfFile.
- XdfIndexer
- Indexes an XDF file in one sequential pass, for XdfFile: stream headers, clock offsets, footers, a summary pyramid per regular stream and where each samples chunk is; irregular streams are kept in memory.
- XdfReader
- Reads little-endian values from bytes, from position on.
- XdfRecording
- A loaded XDF file.
- XdfRecordingSource
- An XDF recording being indexed, here (XdfFile) or in a background isolate (XdfFile.openInBackground).
- XdfSampleChunk
- A samples chunk of a regular stream, decodable on its own.
- XdfSamples
- The samples of one samples chunk.
- XdfStream
- One stream of a loaded XDF file.
- A stream's footer, written when recording stops.
- XdfStreamIndex
- One stream of an XdfFile: its header, and how its samples map to time.
- XdfStreamInfo
-
A stream's header: what LSL says about the stream (its
infoXML). - XdfStreamView
- What a viewer needs of one stream of an indexed XDF recording.
- XdfSyncOptions
- How loadXdf (and XdfFile) process time stamps. The defaults are pyxdf's.
- XdfWriter
- Writes an XDF file to sink as data comes in, like LabRecorder: the file header first, then stream headers, samples, clock offsets and boundaries in any order, and each stream's footer on close.
Enums
- LSLChannelFormat
- The stream info channel formats.
- XdfTag
- Kinds of XDF chunks.
Constants
Functions
-
canDropSamples(
XdfStreamInfo info) → bool -
Whether a stream's header says it can drop samples
(
desc/synchronization/can_drop_samples), e.g. video. -
clockFits(
List< double> times, List<double> values, List<XdfRange> ranges, XdfSyncOptions o) → List<XdfClockFit> -
The clock correction of each range of
timesandvalues(from detectClockResets). -
detectClockResets(
List< double> times, List<double> values, XdfSyncOptions o) → List<XdfRange> - Ranges of clock offsets between clock resets.
-
fillTimestamps(
Float64List ts, double previous, double nominalRate) → double -
Fill the time stamps that
samplesleave out (NaN): the previous one plus 1 /nominalRate(the previous chunk's last isprevious). Returns the last time stamp. -
isXdf(
List< int> bytes) → bool -
Whether
bytesstart like an XDF file. -
loadXdf(
Uint8List bytes, {XdfSyncOptions options = const XdfSyncOptions(), Set< int> ? streamIds}) → XdfRecording -
Load a whole XDF file from
bytes, like pyxdf'sload_xdf: clock synchronisation and jitter removal asoptionssay (pyxdf's defaults). Samples of streams not instreamIds(when given) are skipped. -
readChunkHeader(
Uint8List bytes, int position) → XdfChunkHeader? -
Parse the chunk header at
positionofbytes, or null ifbytesend before it does (at most 11 bytes are needed). -
readChunks(
Uint8List bytes) → Iterable< XdfChunk> - The chunks of a whole XDF file in memory. A truncated last chunk (a recording that was cut off) is left out.
-
readSamples(
Uint8List content, LSLChannelFormat format, int channels, {bool values = true, bool exact = false, void onInexact()?}) → XdfSamples -
Decode a samples chunk's
contentfor a stream offormatwithchannelschannels. Withvaluesfalse, numeric values are skipped (time stamps only). Withexact, they come in the stream's own format (XdfSamples.typed) instead of as doubles.onInexactis called if an int64 value could not be held exactly (beyond 2^53 on the web, or as a double). -
removeJitter(
Float64List ts, double nominalRate, XdfSyncOptions o, {bool canDropSamples = false}) → XdfJitterResult -
Replace the time stamps
tsof a stream atnominalRate(in place) by a least-squares line per segment between breaks, and measure the effective rate. Irregular streams (rate 0) are left alone. WithcanDropSamples(e.g. video), time stamps are kept as they are. -
robustFit(
List< double> x, List<double> y, {double rho = 1, int iters = 1000}) → (double, double) -
Robust linear regression
y ≈ a + b·xwith the Huber loss, solved by ADMM (pyxdf's_robust_fit). Returns(a, b). -
segmentsBetween(
List< bool> breaks) → List<XdfRange> -
Segments of consecutive indices between breaks:
breakshas one entry per pair of neighbours (length n - 1). -
synchronizeClock(
Float64List ts, List< double> times, List<double> values, XdfSyncOptions o) → List<XdfRange> -
Map time stamps
ts(in place) onto the recorder's clock with the clock offsetstimesandvalues. Returns the clock segments: the ranges oftseach correction applies to.
Typedefs
- XdfChannel = LSLChannel
-
One channel as a stream header describes it (
desc/channels/channel). - XdfChunkHeader = ({int contentLength, int contentOffset, int tag})
-
Where a chunk's header says its content is:
contentOffsetandcontentLength(after the tag), with thetag. - XdfClockFit = (double, double)
-
A linear clock correction: add
a + b·tto a time stampt. - XdfFormat = LSLChannelFormat
- How the values of a stream are stored: the LSL channel format.
-
XdfJitterResult
= ({double effectiveRate, List<
XdfRange> segments}) - The result of removeJitter.
- XdfRange = (int, int)
- An inclusive range of indices.