{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n# Cross-hemisphere comparison\n\nThis example illustrates how to visualize the difference between activity in\nthe left and the right hemisphere. The data from the right hemisphere is\nmapped to the left hemisphere, and then the difference is plotted. For more\ninformation see :func:`mne.compute_source_morph`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Author: Christian Brodbeck \n#\n# License: BSD-3-Clause\n# Copyright the MNE-Python contributors." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import mne\n\ndata_dir = mne.datasets.sample.data_path()\nsubjects_dir = data_dir / \"subjects\"\nstc_path = data_dir / \"MEG\" / \"sample\" / \"sample_audvis-meg-eeg\"\nstc = mne.read_source_estimate(stc_path, \"sample\")\n\n# First, morph the data to fsaverage_sym, for which we have left_right\n# registrations:\nstc = mne.compute_source_morph(\n stc, \"sample\", \"fsaverage_sym\", smooth=5, warn=False, subjects_dir=subjects_dir\n).apply(stc)\n\n# Compute a morph-matrix mapping the right to the left hemisphere,\n# and vice-versa.\nmorph = mne.compute_source_morph(\n stc,\n \"fsaverage_sym\",\n \"fsaverage_sym\",\n spacing=stc.vertices,\n warn=False,\n subjects_dir=subjects_dir,\n xhemi=True,\n verbose=\"error\",\n) # creating morph map\nstc_xhemi = morph.apply(stc)\n\n# Now we can subtract them and plot the result:\ndiff = stc - stc_xhemi\n\ndiff.plot(hemi=\"lh\", subjects_dir=subjects_dir, initial_time=0.07, size=(800, 600))" ] } ], "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 }