{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# How to use data in neural ensemble (NEO) format\n\nThis example shows how to create an MNE-Python `~mne.io.Raw` object from data\nin the [neural ensemble](https://neo.readthedocs.io) format. For general\ninformation on creating MNE-Python's data objects from NumPy arrays, see\n`tut-creating-data-structures`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Authors: The MNE-Python contributors.\n# License: BSD-3-Clause\n# Copyright the MNE-Python contributors.\n\nimport neo\n\nimport mne" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example uses NEO's ``ExampleIO`` object for creating fake data. The data will be\nall zeros, so the plot won't be very interesting, but it should demonstrate the steps\nto using NEO data. For actual data and different file formats, consult the NEO\ndocumentation.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reader = neo.io.ExampleIO(\"fakedata.nof\")\nblock = reader.read(lazy=False)[0] # get the first block\nsegment = block.segments[0] # get data from first (and only) segment\nsignals = segment.analogsignals[0] # get first (multichannel) signal\n\ndata = signals.rescale(\"V\").magnitude.T\nsfreq = signals.sampling_rate.magnitude\nch_names = [f\"Neo {(idx + 1):02}\" for idx in range(signals.shape[1])]\nch_types = [\"eeg\"] * len(ch_names) # if not specified, type 'misc' is assumed\n\ninfo = mne.create_info(ch_names=ch_names, ch_types=ch_types, sfreq=sfreq)\nraw = mne.io.RawArray(data, info)\nraw.plot(show_scrollbars=False)" ] } ], "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 }