{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Reading XDF EEG data\n\nHere we read some sample XDF data. Although we do not analyze it here, this\nrecording is of a short parallel auditory response (pABR) experiment\n:footcite:`PolonenkoMaddox2019` and was provided by the [Maddox Lab](https://www.urmc.rochester.edu/labs/maddox.aspx)_.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Authors: Clemens Brunner \n# Eric Larson \n#\n# License: BSD-3-Clause\n# Copyright the MNE-Python contributors." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pyxdf\n\nimport mne\nfrom mne.datasets import misc\n\nfname = misc.data_path() / \"xdf\" / \"sub-P001_ses-S004_task-Default_run-001_eeg_a2.xdf\"\nstreams, header = pyxdf.load_xdf(fname)\ndata = streams[0][\"time_series\"].T\nassert data.shape[0] == 5 # four raw EEG plus one stim channel\ndata[:4:2] -= data[1:4:2] # subtract (rereference) to get two bipolar EEG\ndata = data[::2] # subselect\ndata[:2] *= 1e-6 / 50 / 2 # uV -> V and preamp gain\nsfreq = float(streams[0][\"info\"][\"nominal_srate\"][0])\ninfo = mne.create_info(3, sfreq, [\"eeg\", \"eeg\", \"stim\"])\nraw = mne.io.RawArray(data, info)\nraw.plot(scalings=dict(eeg=100e-6), duration=1, start=14)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## References\n.. footbibliography::\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 0 }