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


Python Raw.notch_filter方法代码示例

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


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

示例1: filter_data

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import notch_filter [as 别名]
def filter_data(subject, l_freq=l_freq, h_freq=h_freq, n_freq=n_freq,
                save=True, n_jobs=1):
    """Filter the data.

    params:
    subject : str
        the subject id to be loaded
    l_freq :  int
        the low frequency to filter
    h_freq : int
        the high frequency to filter
    n_freq : int
        the notch filter frequency
    save : bool
        save the filtered data
    n_jobs : int
        The number of CPUs to use in parallel.
    """
    raw = Raw(maxfiltered_folder + "%s_data_mc_raw_tsss.fif" % subject,
              preload=True)

    if n_freq is not None:
        raw.notch_filter(n_freq, n_jobs=n_jobs)

    raw.filter(l_freq, h_freq, n_jobs=n_jobs)

    if save is True:
        raw.save(save_folder + "%s_filtered_data_mc_raw_tsss.fif" % subject,
                 overwrite=True)
开发者ID:MadsJensen,项目名称:malthe_alpha_project,代码行数:31,代码来源:filter_ICA.py

示例2: dict

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import notch_filter [as 别名]
reject = dict(mag=4e-12, eog=250e-6)

data_path = bst_raw.data_path()

raw_fname = data_path + '/MEG/bst_raw/' + \
                        'subj001_somatosensory_20111109_01_AUX-f_raw.fif'
raw = Raw(raw_fname, preload=True, add_eeg_ref=False)
raw.plot()

# set EOG channel
raw.set_channel_types({'EEG058': 'eog'})
raw.add_eeg_average_proj()

# show power line interference and remove it
raw.plot_psd()
raw.notch_filter(np.arange(60, 181, 60))

events = mne.find_events(raw, stim_channel='UPPT001')

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

# Compute epochs
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=(None, 0), reject=reject, preload=False)

# compute evoked
evoked = epochs.average()

# remove physiological artifacts (eyeblinks, heartbeats) using SSP on baseline
开发者ID:GrantRVD,项目名称:mne-python,代码行数:33,代码来源:plot_brainstorm_data.py

示例3: test_filter

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import notch_filter [as 别名]
def test_filter():
    """Test filtering (FIR and IIR) and Raw.apply_function interface
    """
    raw = Raw(fif_fname).crop(0, 7, False)
    raw.load_data()
    sig_dec = 11
    sig_dec_notch = 12
    sig_dec_notch_fit = 12
    picks_meg = pick_types(raw.info, meg=True, exclude='bads')
    picks = picks_meg[:4]

    filter_params = dict(picks=picks, n_jobs=2, copy=True)
    raw_lp = raw.filter(0., 4.0 - 0.25, **filter_params)
    raw_hp = raw.filter(8.0 + 0.25, None, **filter_params)
    raw_bp = raw.filter(4.0 + 0.25, 8.0 - 0.25, **filter_params)
    raw_bs = raw.filter(8.0 + 0.25, 4.0 - 0.25, **filter_params)

    data, _ = raw[picks, :]

    lp_data, _ = raw_lp[picks, :]
    hp_data, _ = raw_hp[picks, :]
    bp_data, _ = raw_bp[picks, :]
    bs_data, _ = raw_bs[picks, :]

    assert_array_almost_equal(data, lp_data + bp_data + hp_data, sig_dec)
    assert_array_almost_equal(data, bp_data + bs_data, sig_dec)

    filter_params_iir = dict(picks=picks, n_jobs=2, copy=True, method='iir')
    raw_lp_iir = raw.filter(0., 4.0, **filter_params_iir)
    raw_hp_iir = raw.filter(8.0, None, **filter_params_iir)
    raw_bp_iir = raw.filter(4.0, 8.0, **filter_params_iir)
    lp_data_iir, _ = raw_lp_iir[picks, :]
    hp_data_iir, _ = raw_hp_iir[picks, :]
    bp_data_iir, _ = raw_bp_iir[picks, :]
    summation = lp_data_iir + hp_data_iir + bp_data_iir
    assert_array_almost_equal(data[:, 100:-100], summation[:, 100:-100],
                              sig_dec)

    # make sure we didn't touch other channels
    data, _ = raw[picks_meg[4:], :]
    bp_data, _ = raw_bp[picks_meg[4:], :]
    assert_array_equal(data, bp_data)
    bp_data_iir, _ = raw_bp_iir[picks_meg[4:], :]
    assert_array_equal(data, bp_data_iir)

    # ... and that inplace changes are inplace
    raw_copy = raw.copy()
    raw_copy.filter(None, 20., picks=picks, n_jobs=2, copy=False)
    assert_true(raw._data[0, 0] != raw_copy._data[0, 0])
    assert_equal(raw.filter(None, 20., **filter_params)._data,
                 raw_copy._data)

    # do a very simple check on line filtering
    with warnings.catch_warnings(record=True):
        warnings.simplefilter('always')
        raw_bs = raw.filter(60.0 + 0.5, 60.0 - 0.5, **filter_params)
        data_bs, _ = raw_bs[picks, :]
        raw_notch = raw.notch_filter(60.0, picks=picks, n_jobs=2,
                                     method='fft', copy=True)
    data_notch, _ = raw_notch[picks, :]
    assert_array_almost_equal(data_bs, data_notch, sig_dec_notch)

    # now use the sinusoidal fitting
    raw_notch = raw.notch_filter(None, picks=picks, n_jobs=2,
                                 method='spectrum_fit', copy=True)
    data_notch, _ = raw_notch[picks, :]
    data, _ = raw[picks, :]
    assert_array_almost_equal(data, data_notch, sig_dec_notch_fit)
开发者ID:Pablo-Arias,项目名称:mne-python,代码行数:70,代码来源:test_raw_fiff.py

示例4: dict

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import notch_filter [as 别名]
raw_fnormal = scratch_path + "tone_task-tsss-mc-autobad.fif"
raw_fhyp = scratch_path + "hyp_tone_task-tsss-mc-autobad.fif"

reject = dict(
    grad=4000e-13,  # T / m (gradiometers)
    mag=4e-12,  # T (magnetometers)
    #  eog=250e-6  # uV (EOG channels)
)

conditions = ["normal", "hyp"]
for condition in conditions:

    if condition == "normal":
        raw = Raw(raw_fnormal, preload=True)
        raw.filter(1, 90, n_jobs=3)
        raw.notch_filter(50, n_jobs=3)
    elif condition == "hyp":
        raw = Raw(raw_fhyp, preload=True)
        raw.filter(1, 90, n_jobs=3)
        raw.notch_filter(50, n_jobs=3)

    #
    ica = ICA(n_components=0.95, method="fastica")

    picks = mne.pick_types(raw.info, meg=True, eeg=False, eog=False, stim=False, exclude="bads")

    ica.fit(raw, picks=picks, decim=3, reject=reject)

    # maximum number of components to reject
    n_max_ecg, n_max_eog = 3, 1
开发者ID:MadsJensen,项目名称:Hyp_MEG_MNE_2,代码行数:32,代码来源:filter_ICA.py

示例5: dict

# 需要导入模块: from mne.io import Raw [as 别名]
# 或者: from mne.io.Raw import notch_filter [as 别名]
reject_params = dict(grad=4000e-13,  # T / m (gradiometers)
                     mag=4e-12  # T (magnetometers)
                     )

# SETTINGS

#raw = Raw(save_folder + "%s_%s_filtered_mc_tsss-raw.fif" % (subject,
#                                                            condition),
#          preload=True)

raw = Raw(maxfiltered_folder + "%s_%s_mc_tsss-raw.fif" % (subject,
                                                          condition),
          preload=True)
raw.drop_channels(raw.info["bads"])

raw.notch_filter(n_freq, n_jobs=n_jobs)
raw.filter(l_freq, h_freq, n_jobs=n_jobs)

raw.save(save_folder + "%s_%s_filtered_mc_tsss-raw.fif" % (subject,
                                                           condition),
         overwrite=True)



# ICA Part
ica = ICA(n_components=0.99, method='fastica', max_iter=256)

picks = mne.pick_types(raw.info, meg=True, eeg=False, eog=False, emg=False,
                       bio=False, stim=False, exclude='bads')

ica.fit(raw, picks=picks, decim=decim, reject=reject_params)
开发者ID:MadsJensen,项目名称:RP_scripts,代码行数:33,代码来源:ICA_interactive.py


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