示例#1
0
def test_plot_topo():
    """Test plotting of ERP topography
    """
    # Show topography
    evoked = _get_epochs().average()
    plot_topo(evoked, layout)
    warnings.simplefilter('always', UserWarning)
    picked_evoked = pick_channels_evoked(evoked, evoked.ch_names[:3])

    # test scaling
    with warnings.catch_warnings(record=True):
        for ylim in [dict(mag=[-600, 600]), None]:
            plot_topo([picked_evoked] * 2, layout, ylim=ylim)

        for evo in [evoked, [evoked, picked_evoked]]:
            assert_raises(ValueError, plot_topo, evo, layout, color=['y', 'b'])

        evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
        ch_names = evoked_delayed_ssp.ch_names[:3]  # make it faster
        picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp,
                                                         ch_names)
        fig = plot_topo(picked_evoked_delayed_ssp, layout, proj='interactive')
        func = _get_presser(fig)
        event = namedtuple('Event', 'inaxes')
        func(event(inaxes=fig.axes[0]))
示例#2
0
def test_plot_topo():
    """Test plotting of ERP topography
    """
    # Show topography
    evoked = _get_epochs().average()
    plot_topo(evoked, layout)
    warnings.simplefilter('always', UserWarning)
    picked_evoked = pick_channels_evoked(evoked, evoked.ch_names[:3])

    # test scaling
    with warnings.catch_warnings(record=True):
        for ylim in [dict(mag=[-600, 600]), None]:
            plot_topo([picked_evoked] * 2, layout, ylim=ylim)

        for evo in [evoked, [evoked, picked_evoked]]:
            assert_raises(ValueError, plot_topo, evo, layout, color=['y', 'b'])

        evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
        ch_names = evoked_delayed_ssp.ch_names[:3]  # make it faster
        picked_evoked_delayed_ssp = pick_channels_evoked(
            evoked_delayed_ssp, ch_names)
        fig = plot_topo(picked_evoked_delayed_ssp, layout, proj='interactive')
        func = _get_presser(fig)
        event = namedtuple('Event', 'inaxes')
        func(event(inaxes=fig.axes[0]))
示例#3
0
def test_plot_topo():
    """Plot ERP topography
    """

    layout = Layout('Vectorview-all')

    # Show topography
    plot_topo(evoked, layout)
示例#4
0
def test_plot_topo():
    """Test plotting of ERP topography
    """

    layout = read_layout('Vectorview-all')

    # Show topography
    plot_topo(evoked, layout)
示例#5
0
def test_plot_topo():
    """Plot ERP topography
    """

    layout = Layout('Vectorview-all')

    # Show topography
    plot_topo(evoked, layout)
def test_plot_topo():
    """Test plotting of ERP topography
    """
    import matplotlib.pyplot as plt
    # Show topography
    evoked = _get_epochs().average()
    plot_evoked_topo(evoked)  # should auto-find layout
    warnings.simplefilter('always', UserWarning)
    picked_evoked = evoked.pick_channels(evoked.ch_names[:3], copy=True)
    picked_evoked_eeg = evoked.pick_types(meg=False, eeg=True, copy=True)
    picked_evoked_eeg.pick_channels(picked_evoked_eeg.ch_names[:3])

    # test scaling
    with warnings.catch_warnings(record=True):
        for ylim in [dict(mag=[-600, 600]), None]:
            plot_topo([picked_evoked] * 2, layout, ylim=ylim)

        for evo in [evoked, [evoked, picked_evoked]]:
            assert_raises(ValueError, plot_topo, evo, layout, color=['y', 'b'])

        evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
        ch_names = evoked_delayed_ssp.ch_names[:3]  # make it faster
        picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp,
                                                         ch_names)
        fig = plot_topo(picked_evoked_delayed_ssp, layout, proj='interactive')
        func = _get_presser(fig)
        event = namedtuple('Event', 'inaxes')
        func(event(inaxes=fig.axes[0]))
        params = dict(evokeds=[picked_evoked_delayed_ssp],
                      times=picked_evoked_delayed_ssp.times,
                      fig=fig, projs=picked_evoked_delayed_ssp.info['projs'])
        bools = [True] * len(params['projs'])
        _plot_update_evoked_topo(params, bools)
    # should auto-generate layout
    plot_evoked_topo(picked_evoked_eeg.copy(),
                     fig_background=np.zeros((4, 3, 3)), proj=True)
    plt.close('all')
示例#7
0
def test_plot_topo():
    """Test plotting of ERP topography
    """
    # Show topography
    plot_topo(evoked, layout)
    picked_evoked = pick_channels_evoked(evoked, evoked.ch_names[:3])

    # test scaling
    for ylim in [dict(mag=[-600, 600]), None]:
        plot_topo([picked_evoked] * 2, layout, ylim=ylim)

    for evo in [evoked, [evoked, picked_evoked]]:
        assert_raises(ValueError, plot_topo, evo, layout, color=['y', 'b'])

    plot_topo(evoked_delayed_ssp, layout, proj='interactive')
示例#8
0
def test_plot_topo():
    """Test plotting of ERP topography
    """
    # Show topography
    evoked = _get_epochs().average()
    plot_topo(evoked, layout)
    picked_evoked = pick_channels_evoked(evoked, evoked.ch_names[:3])

    # test scaling
    for ylim in [dict(mag=[-600, 600]), None]:
        plot_topo([picked_evoked] * 2, layout, ylim=ylim)

    for evo in [evoked, [evoked, picked_evoked]]:
        assert_raises(ValueError, plot_topo, evo, layout, color=['y', 'b'])

    evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
    plot_topo(evoked_delayed_ssp, layout, proj='interactive')
示例#9
0
def test_plot_topo():
    """Test plotting of ERP topography
    """
    # Show topography
    evoked = _get_epochs().average()
    plot_topo(evoked, layout)
    warnings.simplefilter("always", UserWarning)
    picked_evoked = pick_channels_evoked(evoked, evoked.ch_names[:3])

    # test scaling
    with warnings.catch_warnings(record=True):
        for ylim in [dict(mag=[-600, 600]), None]:
            plot_topo([picked_evoked] * 2, layout, ylim=ylim)

        for evo in [evoked, [evoked, picked_evoked]]:
            assert_raises(ValueError, plot_topo, evo, layout, color=["y", "b"])

        evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
        ch_names = evoked_delayed_ssp.ch_names[:3]  # make it faster
        picked_evoked_delayed_ssp = pick_channels_evoked(evoked_delayed_ssp, ch_names)
        plot_topo(picked_evoked_delayed_ssp, layout, proj="interactive")
示例#10
0
"""
=================================
Plot topographies for MEG sensors
=================================

"""

# Author: Alexandre Gramfort <*****@*****.**>
#
# License: BSD (3-clause)

print __doc__

import pylab as pl

from mne import fiff
from mne.viz import plot_topo
from mne.datasets import sample
data_path = sample.data_path()

fname = data_path + '/MEG/sample/sample_audvis-ave.fif'

# Reading
evoked = fiff.read_evoked(fname, setno=0, baseline=(None, 0))

###############################################################################
# Show topography
title = 'MNE sample data (condition : %s)' % evoked.comment
plot_topo(evoked, title=title)
pl.show()
示例#11
0
=================================
Plot topographies for MEG sensors
=================================

"""
# Author: Alexandre Gramfort <*****@*****.**>
#
# License: BSD (3-clause)

import matplotlib.pyplot as plt

from mne import read_evokeds
from mne.viz import plot_topo
from mne.datasets import sample

print(__doc__)

data_path = sample.data_path()

fname = data_path + '/MEG/sample/sample_audvis-ave.fif'

# Reading
condition = 'Left Auditory'
evoked = read_evokeds(fname, condition=condition, baseline=(None, 0))

###############################################################################
# Show topography
title = 'MNE sample data (condition : %s)' % evoked.comment
plot_topo(evoked, title=title)
plt.show()
示例#12
0
# Syntax is `epochs[condition]`

# In[40]:

epochs_data = epochs['aud_l'].get_data()
print(epochs_data.shape)


# epochs_data is a 3D array of dimension (55 epochs, 365 channels, 106 time instants).

# In[41]:

evokeds = [epochs[k].average() for k in event_id]
from mne.viz import plot_topo
layout = mne.find_layout(epochs.info)
plot_topo(evokeds, layout=layout, color=['blue', 'orange']);


# ## Compute noise covariance

# In[42]:

noise_cov = mne.compute_covariance(epochs, tmax=0.)
print(noise_cov.data.shape)


# In[43]:

fig = mne.viz.plot_cov(noise_cov, raw.info)

raw = Raw(raw_fname)
events = mne.read_events(event_fname)

#   Set up pick list: MEG + STI 014 - bad channels (modify to your needs)
include = []  # or stim channels ['STI 014']
# bad channels in raw.info['bads'] will be automatically excluded

#   Set up amplitude-peak rejection values for MEG channels
reject = dict(grad=4000e-13, mag=4e-12)

# pick MEG channels
picks = pick_types(raw.info, meg=True, eeg=False, stim=False, eog=True,
                   include=include, exclude='bads')

# Create epochs including different events
epochs = mne.Epochs(raw, events, dict(audio_l=1, visual_r=3), tmin, tmax,
                    picks=picks, baseline=(None, 0), reject=reject)

# Generate list of evoked objects from conditions names
evokeds = [epochs[name].average() for name in 'audio_l', 'visual_r']

###############################################################################
# Show topography for two different conditions

layout = read_layout('Vectorview-all.lout')

pl.close('all')
title = 'MNE sample data - left auditory and visual'
plot_topo(evokeds, layout, color=['y', 'g'], title=title)
pl.show()
示例#14
0
def test_plot_topo():
    """Test plotting of ERP topography
    """
    # Show topography
    plot_topo(evoked, layout)
示例#15
0
def test_plot_topo():
    """Test plotting of ERP topography
    """
    # Show topography
    plot_topo(evoked, layout)
                       eog=True,
                       include=include,
                       exclude='bads')

# Create epochs including different events
epochs = mne.Epochs(raw,
                    events,
                    dict(audio_l=1, visual_r=3),
                    tmin,
                    tmax,
                    picks=picks,
                    baseline=(None, 0),
                    reject=reject)

# Generate list of evoked objects from conditions names
evokeds = [epochs[name].average() for name in ('audio_l', 'visual_r')]

###############################################################################
# Show topography for two different conditions

colors = 'yellow', 'green'
title = 'MNE sample data - left auditory and visual'

plot_topo(evokeds, color=colors, title=title)

conditions = [e.comment for e in evokeds]
for cond, col, pos in zip(conditions, colors, (0.025, 0.07)):
    plt.figtext(0.775, pos, cond, color=col, fontsize=12)

plt.show()
示例#17
0
def SensorStatsPlot(condcomb, ListSubj, colors):

    #ListSubj = ('sd130343','cb130477' , 'rb130313', 'jm100109',
    #             'sb120316', 'tk130502','lm130479' , 'ms130534', 'ma100253', 'sl130503',
    #             'mb140004','mp140019' , 'dm130250', 'hr130504', 'wl130316', 'rl130571')

    #ListSubj = ('sd130343','cb130477' , 'rb130313', 'jm100109',
    #             'tk130502','lm130479' , 'ms130534', 'ma100253', 'sl130503',
    #            'mb140004','mp140019' , 'dm130250', 'hr130504', 'rl130571')

    #condcomb = ('QtPast' ,'QtPre','QtFut' )
    #condcomb = ('QsWest' ,'QsPar','QsEast')

    #ipython --pylab
    import mne
    import numpy as np
    import matplotlib.pyplot as plt
    from mpl_toolkits.axes_grid1 import make_axes_locatable
    from mne.viz import plot_topomap
    from mne.stats import spatio_temporal_cluster_test
    from mne.datasets import sample
    from mne.channels import read_ch_connectivity
    from scipy import stats as stats
    from mne.viz import plot_topo
    import os
    os.chdir('/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/SCRIPTS/MNE_PYTHON')
    os.environ['MNE_ROOT'] = '/neurospin/local/mne'
    wdir = "/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/"

    # load FieldTrip neighbor definition to setup sensor connectivity
    neighbor_file_mag = '/neurospin/local/fieldtrip/template/neighbours/neuromag306mag_neighb.mat'  # mag
    neighbor_file_grad = '/neurospin/local/fieldtrip/template/neighbours/neuromag306planar_neighb.mat'  # grad
    neighbor_file_eeg = '/neurospin/local/fieldtrip/template/neighbours/easycap64ch-avg_neighb.mat'  # eeg
    connectivity, ch_names = mne.channels.read_ch_connectivity(
        neighbor_file_eeg, picks=range(60))
    connectivity_mag, ch_names_mag = read_ch_connectivity(neighbor_file_mag)
    connectivity_grad, ch_names_grad = read_ch_connectivity(neighbor_file_grad)
    connectivity_eeg, ch_names_eeg = read_ch_connectivity(neighbor_file_eeg)

    # evoked 0 to get the size of the matrix
    fname0 = (wdir + ListSubj[0] + "/mne_python/MEEG_" + condcomb[0] + "_" +
              ListSubj[0] + "-ave.fif")
    evoked0 = mne.read_evokeds(fname0, condition=0, baseline=(-0.2, 0))
    sensordatamat_meg_mag = np.empty(
        [len(condcomb),
         len(ListSubj), 102, evoked0.data.shape[1]])
    sensordatamat_meg_grad = np.empty(
        [len(condcomb),
         len(ListSubj), 204, evoked0.data.shape[1]])
    sensordatamat_meg_eeg = np.empty(
        [len(condcomb),
         len(ListSubj), 60, evoked0.data.shape[1]])

    # define statistical threshold
    p_threshold = 0.05
    t_threshold = -stats.distributions.t.ppf(p_threshold / 2.,
                                             len(ListSubj) - 1)

    # compute grand averages
    GDAVGmag, GDAVGgrad, GDAVGeeg = [], [], []
    sensordatamat_meg_mag = np.empty(
        (len(condcomb), len(ListSubj), 102, len(evoked0.times)))
    sensordatamat_meg_grad = np.empty(
        (len(condcomb), len(ListSubj), 204, len(evoked0.times)))
    #sensordatamat_eeg       = np.empty((len(condcomb),len(ListSubj),60 ,len(evoked0.times)))

    for c in range(len(condcomb)):

        evoked2plotmag, evoked2plotgrad, evoked2ploteeg = [], [], []
        for i in range(len(ListSubj)):

            fname_ave_meg = (wdir + ListSubj[i] + "/mne_python/MEEG_" +
                             condcomb[c] + "_" + ListSubj[i] + "-ave.fif")

            tmp_evoked_meg = mne.read_evokeds(fname_ave_meg,
                                              condition=0,
                                              baseline=(-0.2, 0))
            evoked2plotmag.append(tmp_evoked_meg.pick_types('mag'))
            sensordatamat_meg_mag[c, i, ::, ::] = tmp_evoked_meg.data

            tmp_evoked_meg = mne.read_evokeds(fname_ave_meg,
                                              condition=0,
                                              baseline=(-0.2, 0))
            evoked2plotgrad.append(tmp_evoked_meg.pick_types('grad'))
            sensordatamat_meg_grad[c, i, ::, ::] = tmp_evoked_meg.data

            #tmp_evoked_meg  = mne.read_evokeds(fname_ave_meg,   condition=0, baseline=(-0.2, 0))
            #evoked2ploteeg.append(tmp_evoked_meg.pick_types('eeg'))
            #sensordatamat_eeg[c,i,::,::]  = tmp_evoked_meg.data

        GDAVGmag.append(mne.grand_average(evoked2plotmag))
        GDAVGgrad.append(mne.grand_average(evoked2plotgrad))
        #GDAVGeeg.append(mne.grand_average(evoked2ploteeg))

    # plot topomaps of grand_averages
    plot_topo(GDAVGmag, color=colors)
    plt.savefig(
        "/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/GROUP/decoding_context_yousra/"
        + "_".join([str(cond) for cond in condcomb]) + "_GDAVG_mags")

    plot_topo(GDAVGgrad, color=colors)
    plt.savefig(
        "/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/GROUP/decoding_context_yousra/"
        + "_".join([str(cond) for cond in condcomb]) + "_GDAVG_grads")

    times = np.arange(-0.1, 0.9, 0.05)
    for c in range(len(condcomb)):

        GDAVGmag[c].plot_topomap(times,
                                 ch_type='mag',
                                 vmin=-40,
                                 vmax=40,
                                 average=0.05)
        plt.savefig(
            "/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/GROUP/decoding_context_yousra/"
            + str(condcomb[c]) + "_GDAVG_mags")

        GDAVGgrad[c].plot_topomap(times,
                                  ch_type='grad',
                                  vmin=-10,
                                  vmax=10,
                                  average=0.05)
        plt.savefig(
            "/neurospin/meg/meg_tmp/MTT_MEG_Baptiste/MEG/GROUP/decoding_context_yousra/"
            + str(condcomb[c]) + "_GDAVG_grads")

    allcond_meg_mag = [
        np.transpose(x, (0, 2, 1)) for x in sensordatamat_meg_mag
    ]
    allcond_meg_grad = [
        np.transpose(x, (0, 2, 1)) for x in sensordatamat_meg_grad
    ]

    ###############################################################################

    t_threshold = -stats.distributions.t.ppf(0 / 2, len(ListSubj) - 1)
    T_obs, clusters, cluster_p_values, HO = spatio_temporal_cluster_test(
        allcond_meg_mag[0::1],
        n_permutations=1024,
        threshold=t_threshold,
        tail=0,
        n_jobs=4,
        connectivity=connectivity_mag)

    t_threshold = -stats.distributions.t.ppf(0 / 2, len(ListSubj) - 1)
    T_obs, clusters, cluster_p_values, HO = spatio_temporal_cluster_test(
        allcond_meg_grad,
        n_permutations=1024,
        threshold=t_threshold,
        tail=0,
        n_jobs=4,
        connectivity=connectivity_grad)
picks = pick_types(raw.info,
                   meg=True,
                   eeg=False,
                   stim=False,
                   eog=True,
                   include=include,
                   exclude='bads')

# Create epochs including different events
epochs = mne.Epochs(raw,
                    events,
                    dict(audio_l=1, visual_r=3),
                    tmin,
                    tmax,
                    picks=picks,
                    baseline=(None, 0),
                    reject=reject)

# Generate list of evoked objects from conditions names
evokeds = [epochs[name].average() for name in 'audio_l', 'visual_r']

###############################################################################
# Show topography for two different conditions

layout = read_layout('Vectorview-all.lout')

pl.close('all')
title = 'MNE sample data - left auditory and visual'
plot_topo(evokeds, layout, color=['y', 'g'], title=title)
pl.show()
示例#19
0
=================================

"""

# Author: Alexandre Gramfort <*****@*****.**>
#
# License: BSD (3-clause)

print __doc__

import pylab as pl

from mne import fiff
from mne.layouts import read_layout
from mne.viz import plot_topo
from mne.datasets import sample
data_path = sample.data_path()

fname = data_path + '/MEG/sample/sample_audvis-ave.fif'

# Reading
evoked = fiff.read_evoked(fname, setno=0, baseline=(None, 0))

layout = read_layout('Vectorview-all')

###############################################################################
# Show topography
title = 'MNE sample data (condition : %s)' % evoked.comment
plot_topo(evoked, layout, title=title)
pl.show()
include = []  # or stim channels ['STI 014']
# bad channels in raw.info['bads'] will be automatically excluded

#   Set up amplitude-peak rejection values for MEG channels
reject = dict(grad=4000e-13, mag=4e-12)

# pick MEG channels
picks = mne.pick_types(raw.info, meg=True, eeg=False, stim=False, eog=True,
                       include=include, exclude='bads')

# Create epochs including different events
epochs = mne.Epochs(raw, events, dict(audio_l=1, visual_r=3), tmin, tmax,
                    picks=picks, baseline=(None, 0), reject=reject)

# Generate list of evoked objects from conditions names
evokeds = [epochs[name].average() for name in ('audio_l', 'visual_r')]

###############################################################################
# Show topography for two different conditions

colors = 'yellow', 'green'
title = 'MNE sample data - left auditory and visual'

plot_topo(evokeds, color=colors, title=title)

conditions = [e.comment for e in evokeds]
for cond, col, pos in zip(conditions, colors, (0.025, 0.07)):
    plt.figtext(0.775, pos, cond, color=col, fontsize=12)

plt.show()
示例#21
0
"""

# Author: Alexandre Gramfort <*****@*****.**>
#
# License: BSD (3-clause)

print __doc__

import pylab as pl

from mne import fiff
from mne.layouts import Layout
from mne.viz import plot_topo
from mne.datasets import sample
data_path = sample.data_path('.')

fname = data_path + '/MEG/sample/sample_audvis-ave.fif'

# Reading
evoked = fiff.read_evoked(fname, setno=0, baseline=(None, 0))

layout = Layout('Vectorview-all')

###############################################################################
# Show topography
plot_topo(evoked, layout)
title = 'MNE sample data (condition : %s)' % evoked.comment
pl.figtext(0.03, 0.93, title, color='w', fontsize=18)
pl.show()