{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Optically pumped magnetometer (OPM) data\n\nIn this dataset, electrical median nerve stimulation was delivered to the\nleft wrist of the subject. Somatosensory evoked fields were measured using\nnine QuSpin SERF OPMs placed over the right-hand side somatomotor area. Here\nwe demonstrate how to localize these custom OPM data in MNE.\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\n\nimport numpy as np\n\nimport mne\n\ndata_path = mne.datasets.opm.data_path()\nsubject = \"OPM_sample\"\nsubjects_dir = data_path / \"subjects\"\nraw_fname = data_path / \"MEG\" / \"OPM\" / \"OPM_SEF_raw.fif\"\nbem_fname = subjects_dir / subject / \"bem\" / f\"{subject}-5120-5120-5120-bem-sol.fif\"\nfwd_fname = data_path / \"MEG\" / \"OPM\" / \"OPM_sample-fwd.fif\"\ncoil_def_fname = data_path / \"MEG\" / \"OPM\" / \"coil_def.dat\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Prepare data for localization\nFirst we filter and epoch the data:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "raw = mne.io.read_raw_fif(raw_fname, preload=True)\nraw.filter(None, 90, h_trans_bandwidth=10.0)\nraw.notch_filter(50.0, notch_widths=1)\n\n\n# Set epoch rejection threshold a bit larger than for SQUIDs\nreject = dict(mag=2e-10)\ntmin, tmax = -0.5, 1\n\n# Find median nerve stimulator trigger\nevent_id = dict(Median=257)\nevents = mne.find_events(raw, stim_channel=\"STI101\", mask=257, mask_type=\"and\")\npicks = mne.pick_types(raw.info, meg=True, eeg=False)\n# We use verbose='error' to suppress warning about decimation causing aliasing,\n# ideally we would low-pass and then decimate instead\nepochs = mne.Epochs(\n raw,\n events,\n event_id,\n tmin,\n tmax,\n verbose=\"error\",\n reject=reject,\n picks=picks,\n proj=False,\n decim=10,\n preload=True,\n)\nevoked = epochs.average()\nevoked.plot()\ncov = mne.compute_covariance(epochs, tmax=0.0)\ndel epochs, raw" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Examine our coordinate alignment for source localization and compute a\nforward operator:\n\n
The Head<->MRI transform is an identity matrix, as the\n co-registration method used equates the two coordinate\n systems. This mis-defines the head coordinate system\n (which should be based on the LPA, Nasion, and RPA)\n but should be fine for these analyses.