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


Python Raw.estimate_rank方法代码示例

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


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

示例1: test_rank_estimation

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import estimate_rank [as 别名]
def test_rank_estimation():
    """Test raw rank estimation
    """
    iter_tests = itt.product([fif_fname, hp_fif_fname], ["norm", dict(mag=1e11, grad=1e9, eeg=1e5)])  # sss
    for fname, scalings in iter_tests:
        raw = Raw(fname)
        (_, picks_meg), (_, picks_eeg) = _picks_by_type(raw.info, meg_combined=True)
        n_meg = len(picks_meg)
        n_eeg = len(picks_eeg)

        raw = Raw(fname, preload=True)
        if "proc_history" not in raw.info:
            expected_rank = n_meg + n_eeg
        else:
            mf = raw.info["proc_history"][0]["max_info"]
            expected_rank = _get_sss_rank(mf) + n_eeg
        assert_array_equal(raw.estimate_rank(scalings=scalings), expected_rank)

        assert_array_equal(raw.estimate_rank(picks=picks_eeg, scalings=scalings), n_eeg)

        raw = Raw(fname, preload=False)
        if "sss" in fname:
            tstart, tstop = 0.0, 30.0
            raw.add_proj(compute_proj_raw(raw))
            raw.apply_proj()
        else:
            tstart, tstop = 10.0, 20.0

        raw.apply_proj()
        n_proj = len(raw.info["projs"])

        assert_array_equal(
            raw.estimate_rank(tstart=tstart, tstop=tstop, scalings=scalings),
            expected_rank - (1 if "sss" in fname else n_proj),
        )
开发者ID:jasmainak,项目名称:mne-python,代码行数:37,代码来源:test_raw.py

示例2: test_rank_estimation

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import estimate_rank [as 别名]
def test_rank_estimation():
    """Test raw rank estimation
    """
    raw = Raw(fif_fname)
    n_meg = len(pick_types(raw.info, meg=True, eeg=False, exclude='bads'))
    n_eeg = len(pick_types(raw.info, meg=False, eeg=True, exclude='bads'))
    raw = Raw(fif_fname, preload=True)
    assert_array_equal(raw.estimate_rank(), n_meg + n_eeg)
    raw = Raw(fif_fname, preload=False)
    raw.apply_proj()
    n_proj = len(raw.info['projs'])
    assert_array_equal(raw.estimate_rank(tstart=10, tstop=20),
                       n_meg + n_eeg - n_proj)
开发者ID:kingjr,项目名称:mne-python,代码行数:15,代码来源:test_raw.py

示例3: test_ica_rank_reduction

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import estimate_rank [as 别名]
def test_ica_rank_reduction():
    """Test recovery of full data when no source is rejected"""
    # Most basic recovery
    raw = Raw(raw_fname).crop(0.5, stop, False)
    raw.load_data()
    picks = pick_types(raw.info, meg=True, stim=False, ecg=False,
                       eog=False, exclude='bads')[:10]
    n_components = 5
    max_pca_components = len(picks)
    for n_pca_components in [6, 10]:
        with warnings.catch_warnings(record=True):  # non-convergence
            warnings.simplefilter('always')
            ica = ICA(n_components=n_components,
                      max_pca_components=max_pca_components,
                      n_pca_components=n_pca_components,
                      method='fastica', max_iter=1).fit(raw, picks=picks)

        rank_before = raw.estimate_rank(picks=picks)
        assert_equal(rank_before, len(picks))
        raw_clean = ica.apply(raw, copy=True)
        rank_after = raw_clean.estimate_rank(picks=picks)
        # interaction between ICA rejection and PCA components difficult
        # to preduct. Rank_after often seems to be 1 higher then
        # n_pca_components
        assert_true(n_components < n_pca_components <= rank_after <=
                    rank_before)
开发者ID:mdclarke,项目名称:mne-python,代码行数:28,代码来源:test_ica.py

示例4: Raw

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import estimate_rank [as 别名]
        if 'empty' not in cond:
            
            raw_path = ad._scratch_folder + '/' + input_files + '/' + subj
            in_fnames = ad.analysis_dict[subj][input_files][cond]['files'] 
            for fname in in_fnames:
                print 'In: ', fname
                # 1) Fit ICA model using the FastICA algorithm

                # Other available choices are `infomax` or `extended-infomax`
                # We pass a float value between 0 and 1 to select n_components based on the
                # percentage of variance explained by the PCA components.

                raw = Raw(fname, preload=True)
                picks = mne.pick_types(raw.info, meg=True, eeg=False, 
                        eog=False, ecg=False, stim=False, exclude='bads')

                if rank_estimate is None:
                    # estimate the rank only for the second VS task
                    # use 300 seconds
                    rank_estimate = raw.estimate_rank(tstart=240., tstop=540., picks=picks)
                    print 'Estimated raw to be of rank', rank_estimate

                ica = ICA(n_components=rank_estimate, max_pca_components = None, 
                        max_iter=256, method='fastica')

                ica.fit(raw, picks=picks, decim = 5, reject=dict(mag=4e-11, grad=4000e-12))
                # Save with information on excludes!
                ica.save(outdir + '/' + cond + '-ica.fif')
                

开发者ID:cjayb,项目名称:VSC-MEG-analysis,代码行数:30,代码来源:scr_run_estimate_ica.py

示例5: dict

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import estimate_rank [as 别名]
# Set epoch parameters
tmin, tmax = -0.4, 0.6  # no need to take more than this, wide enough to see eyemov though
rej_tmin, rej_tmax = -0.2, 0.3  # reject trial only if blinks in the 500 ms middle portion!
baseline = (-0.2, 0.)
reject = dict(eog=150e-6, mag=4e-12, grad=4000e-13) # compare to standard rejection
ica_reject = dict(eog=300-6, mag=5e-12, grad=5000e-13) # compare to standard rejection

raw_path = ad._scratch_folder + '/tsss_initial/007_SGF'
img_folder = ad._scratch_folder + '/tsss_initial/007_SGF/img/epochs'
eve_path = ad._scratch_folder + '/events.fif/007_SGF/raw'

fname = raw_path + '/VS_1a_1_tsss_mc.fif'

raw = Raw(fname, preload=True)
picks = pick_types(raw.info, meg=True, eog=True)
n_components = raw.estimate_rank(picks=picks)
print 'Estimated raw to be of rank', n_components
n_max_eog = 3
title = 'Sources related to %s artifacts (red)'

#ica = read_ica(raw_path + '/ica_pre.fif')
#print 'Excluding', ica.exclude
#raw_ica = ica.apply(raw, copy=True)

events = mne.read_events(eve_path + '/VS_1a_1-eve.fif')
eve_dict, id_dict = split_events_by_trialtype(events)
for trial_type in ['VS']:

    epochs = mne.Epochs(raw, eve_dict[trial_type], id_dict,
                        tmin, tmax, picks=picks, verbose=False,
                        baseline=baseline, reject=reject, preload=True,
开发者ID:cjayb,项目名称:VSC-MEG-analysis,代码行数:33,代码来源:plot_ica_from_epochs_example.py


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