{ "nbformat_minor": 0, "nbformat": 4, "cells": [ { "execution_count": null, "cell_type": "code", "source": [ "%matplotlib inline" ], "outputs": [], "metadata": { "collapsed": false } }, { "source": [ "\n===================================================================\nCompute cross-talk functions (CTFs) for labels for MNE/dSPM/sLORETA\n===================================================================\n\nCTFs are computed for four labels in the MNE sample data set\nfor linear inverse operators (MNE, dSPM, sLORETA).\nCTFs describe the sensitivity of a linear estimator (e.g. for\none label) to sources across the cortical surface. Sensitivity\nto sources outside the label is undesirable, and referred to as\n\"leakage\" or \"cross-talk\".\n\n" ], "cell_type": "markdown", "metadata": {} }, { "execution_count": null, "cell_type": "code", "source": [ "# Author: Olaf Hauk \n#\n# License: BSD (3-clause)\n\nfrom mayavi import mlab\n\nimport mne\nfrom mne.datasets import sample\nfrom mne.minimum_norm import cross_talk_function, read_inverse_operator\n\nprint(__doc__)\n\ndata_path = sample.data_path()\nsubjects_dir = data_path + '/subjects/'\nfname_fwd = data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif'\nfname_inv = data_path + '/MEG/sample/sample_audvis-meg-oct-6-meg-inv.fif'\nfname_evoked = data_path + '/MEG/sample/sample_audvis-ave.fif'\nfname_label = [data_path + '/MEG/sample/labels/Aud-rh.label',\n data_path + '/MEG/sample/labels/Aud-lh.label',\n data_path + '/MEG/sample/labels/Vis-rh.label',\n data_path + '/MEG/sample/labels/Vis-lh.label']\n\n# read forward solution\nforward = mne.read_forward_solution(fname_fwd)\n\n# read label(s)\nlabels = [mne.read_label(ss) for ss in fname_label]\n\ninverse_operator = read_inverse_operator(fname_inv)\n\n# regularisation parameter\nsnr = 3.0\nlambda2 = 1.0 / snr ** 2\nmode = 'svd'\nn_svd_comp = 1\n\nmethod = 'MNE' # can be 'MNE', 'dSPM', or 'sLORETA'\nstc_ctf_mne = cross_talk_function(\n inverse_operator, forward, labels, method=method, lambda2=lambda2,\n signed=False, mode=mode, n_svd_comp=n_svd_comp)\n\nmethod = 'dSPM'\nstc_ctf_dspm = cross_talk_function(\n inverse_operator, forward, labels, method=method, lambda2=lambda2,\n signed=False, mode=mode, n_svd_comp=n_svd_comp)\n\ntime_label = \"MNE %d\"\nbrain_mne = stc_ctf_mne.plot(hemi='rh', subjects_dir=subjects_dir,\n time_label=time_label,\n figure=mlab.figure(size=(500, 500)))\n\ntime_label = \"dSPM %d\"\nbrain_dspm = stc_ctf_dspm.plot(hemi='rh', subjects_dir=subjects_dir,\n time_label=time_label,\n figure=mlab.figure(size=(500, 500)))\n\n# Cross-talk functions for MNE and dSPM (and sLORETA) have the same shapes\n# (they may still differ in overall amplitude).\n# Point-spread functions (PSfs) usually differ significantly." ], "outputs": [], "metadata": { "collapsed": false } } ], "metadata": { "kernelspec": { "display_name": "Python 2", "name": "python2", "language": "python" }, "language_info": { "mimetype": "text/x-python", "nbconvert_exporter": "python", "name": "python", "file_extension": ".py", "version": "2.7.13", "pygments_lexer": "ipython2", "codemirror_mode": { "version": 2, "name": "ipython" } } } }