PyXDF is a Python importer for XDF files.
The following example loads minimal.xdf (which you can download from here) and prints/plots all markers:
import matplotlib.pyplot as plt
import numpy as np
import pyxdf
data, header = pyxdf.load_xdf("minimal.xdf")
for stream in data:
y = stream["time_series"]
if isinstance(y, list):
# list of strings, draw one vertical line for each marker
for timestamp, marker in zip(stream["time_stamps"], y):
plt.axvline(x=timestamp)
print(f'Marker "{marker[0]}" @ {timestamp:.2f}s')
elif isinstance(y, np.ndarray):
# numeric data, draw as lines
plt.plot(stream["time_stamps"], y)
else:
raise RuntimeError("Unknown stream format")
plt.show()Note that you need to have matplotlib installed to run this example (which is not a dependency of PyXDF itself).
PyXDF has a command line interface (CLI) with the following commands:
print_metadatawill print basic metadata for each found stream.python -m pyxdf.cli.print_metadata -f=/path/to/my.xdf
playback_lslwill open an XDF file, then replay its data in an infinite loop, but using current timestamps (this is useful for prototyping online processing):python -m pyxdf.cli.playback_lsl /path/to/my.xdf --loop
The latest stable version can be installed with pip install pyxdf.
For the latest development version, use pip install git+https://github.com/xdf-modules/pyxdf.git.
As soon as a new release is created on GitHub (using a tag labeled e.g. v1.16.3), a PyPI package is automatically created with the version number matching the release tag.