xdffileio provides a unified interface to read/write EEG file format in realtime. It has been designed to provide a consistent and common interface to all supported file formats while minimizing the CPU cost on the main loop. It thus performs all the expensive operation (scaling, data convertion and file operation) in a separated thread.
The library does not support non-continous recording neither channels sampled at different sampling rate.
By design of the library, a call to the write operation is “almost” ensured to be executed in a linear time, i.e. given a fixed configuration of an xDF file, for the same number of samples to be passed, a call
xdf_write will almost take always the same time to complete. This time increases linearly with the number of samples. This insurance is particularly useful for realtime processing of data, since storing the data will impact the main loop in a predictible way.
This is achieved by double buffering the data for writing. A front and a back buffer are available: the front buffer is filled with the incoming data, and swapped with the back buffer when full. This swap signals a background thread to convert, reorganise, scale and save to the disk the data contained in the full buffer making it afterwards available for the next swap.
This approach ensures a linear calltime of
xdf_write providing that I/O subsystem is not saturated neither all processing units (cores or processors), i.e. the application is neither I/O bound nor CPU bound.
The xdffileio library makes sure that data written to xDF files are safely stored on stable storage on a regular basis but because of double buffering, there is a risk to loose data in case of problem. However, the design of the write operation ensures that if a problem occurs (no more disk space, power supply cut), at most two records of data plus the size of the chunks of data supplied to the function will be lost.
As an example, assuming you record a xDF file at 256Hz using records of 256 samples and you feed the library with chunks of 8 samples, you are ensured to receive notification of failure after at most 520 samples corresponding to a lose of at most a little more than 2s of data in case of problems.
xdffileio library should compile and run on any POSIX platform (GNU/Linux, MaxOSX, BSD…) as well on Windows platforms.
The library is shipped with manpages and example codes
The library does not depend on any none standard library. The only missing dependency can be the POSIX thread library (pthread) on Windows platform. Some distribution of MingW ship it. Otherwise you can download pthread-win32