{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Compare evoked responses for different conditions\n\nIn this example, an Epochs object for visual and auditory responses is created.\nBoth conditions are then accessed by their respective names to create a sensor\nlayout plot of the related evoked responses.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Authors: Denis Engemann \n# Alexandre Gramfort \n\n# License: BSD-3-Clause\n# Copyright the MNE-Python contributors." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nimport mne\nfrom mne.datasets import sample\nfrom mne.viz import plot_evoked_topo\n\nprint(__doc__)\n\ndata_path = sample.data_path()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set parameters.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "meg_path = data_path / \"MEG\" / \"sample\"\nraw_fname = meg_path / \"sample_audvis_filt-0-40_raw.fif\"\nevent_fname = meg_path / \"sample_audvis_filt-0-40_raw-eve.fif\"\ntmin = -0.2\ntmax = 0.5\n\n# Setup for reading the raw data.\nraw = mne.io.read_raw_fif(raw_fname)\nevents = mne.read_events(event_fname)\n\n# Set up amplitude-peak rejection values for MEG channels.\nreject = dict(grad=4000e-13, mag=4e-12)\n\n# Create epochs including different events.\nevent_id = {\"audio/left\": 1, \"audio/right\": 2, \"visual/left\": 3, \"visual/right\": 4}\nepochs = mne.Epochs(\n raw, events, event_id, tmin, tmax, picks=\"meg\", baseline=(None, 0), reject=reject\n)\n\n# Generate list of evoked objects from conditions names\nevokeds = [epochs[name].average() for name in (\"left\", \"right\")]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Show topography for two different conditions.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "colors = \"blue\", \"red\"\ntitle = \"MNE sample data\\nleft vs right (A/V combined)\"\n\nplot_evoked_topo(evokeds, color=colors, title=title, background_color=\"w\")\n\nplt.show()" ] } ], "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 }