当前位置: 首页>>代码示例>>Python>>正文


Python ICA.plot_properties方法代码示例

本文整理汇总了Python中mne.preprocessing.ICA.plot_properties方法的典型用法代码示例。如果您正苦于以下问题:Python ICA.plot_properties方法的具体用法?Python ICA.plot_properties怎么用?Python ICA.plot_properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mne.preprocessing.ICA的用法示例。


在下文中一共展示了ICA.plot_properties方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_plot_ica_properties

# 需要导入模块: from mne.preprocessing import ICA [as 别名]
# 或者: from mne.preprocessing.ICA import plot_properties [as 别名]
def test_plot_ica_properties():
    """Test plotting of ICA properties."""
    import matplotlib.pyplot as plt

    raw = _get_raw(preload=True)
    raw.add_proj([], remove_existing=True)
    events = _get_events()
    picks = _get_picks(raw)[:6]
    pick_names = [raw.ch_names[k] for k in picks]
    raw.pick_channels(pick_names)

    with warnings.catch_warnings(record=True):  # bad proj
        epochs = Epochs(raw, events[:10], event_id, tmin, tmax, baseline=(None, 0), preload=True)

    ica = ICA(noise_cov=read_cov(cov_fname), n_components=2, max_pca_components=2, n_pca_components=2)
    with warnings.catch_warnings(record=True):  # bad proj
        ica.fit(raw)

    # test _create_properties_layout
    fig, ax = _create_properties_layout()
    assert_equal(len(ax), 5)

    topoargs = dict(topomap_args={"res": 10})
    ica.plot_properties(raw, picks=0, **topoargs)
    ica.plot_properties(epochs, picks=1, dB=False, plot_std=1.5, **topoargs)
    ica.plot_properties(
        epochs,
        picks=1,
        image_args={"sigma": 1.5},
        topomap_args={"res": 10, "colorbar": True},
        psd_args={"fmax": 65.0},
        plot_std=False,
        figsize=[4.5, 4.5],
    )
    plt.close("all")

    assert_raises(ValueError, ica.plot_properties, epochs, dB=list("abc"))
    assert_raises(ValueError, ica.plot_properties, epochs, plot_std=[])
    assert_raises(ValueError, ica.plot_properties, ica)
    assert_raises(ValueError, ica.plot_properties, [0.2])
    assert_raises(ValueError, plot_ica_properties, epochs, epochs)
    assert_raises(ValueError, ica.plot_properties, epochs, psd_args="not dict")

    fig, ax = plt.subplots(2, 3)
    ax = ax.ravel()[:-1]
    ica.plot_properties(epochs, picks=1, axes=ax)
    fig = ica.plot_properties(raw, picks=[0, 1], **topoargs)
    assert_equal(len(fig), 2)
    assert_raises(ValueError, plot_ica_properties, epochs, ica, picks=[0, 1], axes=ax)
    assert_raises(ValueError, ica.plot_properties, epochs, axes="not axes")
    plt.close("all")
开发者ID:nwilming,项目名称:mne-python,代码行数:53,代码来源:test_ica.py

示例2: print

# 需要导入模块: from mne.preprocessing import ICA [as 别名]
# 或者: from mne.preprocessing.ICA import plot_properties [as 别名]
print(ica)

###############################################################################
# Plot ICA components

ica.plot_components()  # can you spot some potential bad guys?


###############################################################################
# Component properties
# --------------------
#
# Let's take a closer look at properties of first three independent components.

# first, component 0:
ica.plot_properties(raw, picks=0)

###############################################################################
# we can see that the data were filtered so the spectrum plot is not
# very informative, let's change that:
ica.plot_properties(raw, picks=0, psd_args={'fmax': 35.})

###############################################################################
# we can also take a look at multiple different components at once:
ica.plot_properties(raw, picks=[1, 2], psd_args={'fmax': 35.})

###############################################################################
# Instead of opening individual figures with component properties, we can
# also pass an instance of Raw or Epochs in ``inst`` arument to
# ``ica.plot_components``. This would allow us to open component properties
# interactively by clicking on individual component topomaps. In the notebook
开发者ID:jmontoyam,项目名称:mne-python,代码行数:33,代码来源:plot_artifacts_correction_ica.py

示例3: test_plot_ica_properties

# 需要导入模块: from mne.preprocessing import ICA [as 别名]
# 或者: from mne.preprocessing.ICA import plot_properties [as 别名]
def test_plot_ica_properties():
    """Test plotting of ICA properties."""
    import matplotlib.pyplot as plt

    res = 8
    raw = _get_raw(preload=True)
    raw.add_proj([], remove_existing=True)
    events = _get_events()
    picks = _get_picks(raw)[:6]
    pick_names = [raw.ch_names[k] for k in picks]
    raw.pick_channels(pick_names)

    epochs = Epochs(raw, events[:10], event_id, tmin, tmax,
                    baseline=(None, 0), preload=True)

    ica = ICA(noise_cov=read_cov(cov_fname), n_components=2,
              max_pca_components=2, n_pca_components=2)
    with pytest.warns(RuntimeWarning, match='projection'):
        ica.fit(raw)

    # test _create_properties_layout
    fig, ax = _create_properties_layout()
    assert_equal(len(ax), 5)

    topoargs = dict(topomap_args={'res': res, 'contours': 0, "sensors": False})
    ica.plot_properties(raw, picks=0, **topoargs)
    ica.plot_properties(epochs, picks=1, dB=False, plot_std=1.5, **topoargs)
    ica.plot_properties(epochs, picks=1, image_args={'sigma': 1.5},
                        topomap_args={'res': 10, 'colorbar': True},
                        psd_args={'fmax': 65.}, plot_std=False,
                        figsize=[4.5, 4.5])
    plt.close('all')

    pytest.raises(TypeError, ica.plot_properties, epochs, dB=list('abc'))
    pytest.raises(TypeError, ica.plot_properties, ica)
    pytest.raises(TypeError, ica.plot_properties, [0.2])
    pytest.raises(TypeError, plot_ica_properties, epochs, epochs)
    pytest.raises(TypeError, ica.plot_properties, epochs,
                  psd_args='not dict')
    pytest.raises(ValueError, ica.plot_properties, epochs, plot_std=[])

    fig, ax = plt.subplots(2, 3)
    ax = ax.ravel()[:-1]
    ica.plot_properties(epochs, picks=1, axes=ax, **topoargs)
    fig = ica.plot_properties(raw, picks=[0, 1], **topoargs)
    assert_equal(len(fig), 2)
    pytest.raises(TypeError, plot_ica_properties, epochs, ica, picks=[0, 1],
                  axes=ax)
    pytest.raises(ValueError, ica.plot_properties, epochs, axes='not axes')
    plt.close('all')

    # Test merging grads.
    raw = _get_raw(preload=True)
    picks = pick_types(raw.info, meg='grad')[:10]
    ica = ICA(n_components=2)
    ica.fit(raw, picks=picks)
    ica.plot_properties(raw)
    plt.close('all')
开发者ID:SherazKhan,项目名称:mne-python,代码行数:60,代码来源:test_ica.py

示例4: ICA

# 需要导入模块: from mne.preprocessing import ICA [as 别名]
# 或者: from mne.preprocessing.ICA import plot_properties [as 别名]
#
# - 1 - 30 Hz band-pass IIR filter
#
# - epoching -0.2 to 0.5 seconds with respect to events

data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'

raw = mne.io.read_raw_fif(raw_fname, preload=True)
raw.pick_types(meg=True, eeg=False, exclude='bads', stim=True)
raw.filter(1, 30)

# longer + more epochs for more artifact exposure
events = mne.find_events(raw, stim_channel='STI 014')
epochs = mne.Epochs(raw, events, event_id=None, tmin=-0.2, tmax=0.5)

###############################################################################
# Fit ICA model using the FastICA algorithm, detect and plot components
# explaining ECG artifacts.

ica = ICA(n_components=0.95, method='fastica').fit(epochs)

ecg_epochs = create_ecg_epochs(raw, tmin=-.5, tmax=.5)
ecg_inds, scores = ica.find_bads_ecg(ecg_epochs)

ica.plot_components(ecg_inds)

###############################################################################
# Plot properties of ECG components:
ica.plot_properties(epochs, picks=ecg_inds)
开发者ID:deep-introspection,项目名称:mne-python,代码行数:32,代码来源:plot_run_ica.py

示例5: create_ecg_epochs

# 需要导入模块: from mne.preprocessing import ICA [as 别名]
# 或者: from mne.preprocessing.ICA import plot_properties [as 别名]
    del eog_epochs, eog_average

    # ECG
    ecg_epochs = create_ecg_epochs(raw, tmin=-.5, tmax=.5)
    ecg_inds, scores = ica.find_bads_ecg(ecg_epochs)
    ecg_inds = ecg_inds[:n_max_ecg]
    ica.exclude.extend(ecg_inds)

    if ecg_inds:
        fig = ica.plot_components(
            ecg_inds, title=title % ('ecg', subject), colorbar=True)
        fig.savefig(ica_folder + "plots/%s_%s_ecg_component_2.png" % (
            subject, condition))
        fig = ica.plot_overlay(raw, exclude=ecg_inds, show=False)
        fig.savefig(ica_folder + "plots/%s_%s_ecg_excluded_2.png" % (
            subject, condition))
        fig = ica.plot_properties(raw, picks=ecg_inds)
        fig[0].savefig(ica_folder + "plots/%s_%s_plot_properties_2.png" % (
            subject, condition))

    ##########################################################################
    # Apply the solution to Raw, Epochs or Evoked like this:
    raw_ica = ica.apply(raw)
    ica.save(ica_folder + "%s_%s-ica_2.fif" % (subject, condition))  # save ICA
    # componenets
    # Save raw with ICA removed
    raw_ica.save(
        ica_folder + "%s_%s_ica-raw.fif" % (subject, condition),
        overwrite=True)
开发者ID:MadsJensen,项目名称:RP_scripts,代码行数:31,代码来源:filter_ICA.py

示例6:

# 需要导入模块: from mne.preprocessing import ICA [as 别名]
# 或者: from mne.preprocessing.ICA import plot_properties [as 别名]
        fig = ica.plot_scores(
            scores, exclude=eog_inds, title=title % ('eog', subject))
        fig.savefig(ica_folder + "plots/%s_%s_eog_scores.png" % (subject,
                                                                 condition))
        fig = ica.plot_sources(epochs, exclude=eog_inds)
        fig.savefig(ica_folder + "plots/%s_%s_eog_source.png" % (subject,
                                                                 condition))

        fig = ica.plot_components(
            eog_inds, title=title % ('eog', subject), colorbar=True)
        fig.savefig(ica_folder + "plots/%s_%s_eog_component.png" % (subject,
                                                                    condition))
        fig = ica.plot_overlay(epochs.average(), exclude=eog_inds, show=False)
        fig.savefig(ica_folder + "plots/%s_%s_eog_excluded.png" % (subject,
                                                                   condition))
        fig = ica.plot_properties(epochs, picks=eog_inds)
        fig[0].savefig(ica_folder + "plots/%s_%s_plot_properties.png" % (
            subject, condition))

    # ECG
    ecg_inds, scores = ica.find_bads_ecg(epochs)
    ica.exclude += ecg_inds

    if ecg_inds:
        fig = ica.plot_components(
            ecg_inds, title=title % ('ecg', subject), colorbar=True)
        fig.savefig(ica_folder + "plots/%s_%s_ecg_component.png" % (subject,
                                                                    condition))
        fig = ica.plot_overlay(epochs.average(), exclude=ecg_inds, show=False)
        fig.savefig(ica_folder + "plots/%s_%s_ecg_excluded.png" % (subject,
                                                                   condition))
开发者ID:MadsJensen,项目名称:RP_scripts,代码行数:33,代码来源:ica_clean_data.py


注:本文中的mne.preprocessing.ICA.plot_properties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。