本文整理汇总了Python中mne.io.RawArray.filter方法的典型用法代码示例。如果您正苦于以下问题:Python RawArray.filter方法的具体用法?Python RawArray.filter怎么用?Python RawArray.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mne.io.RawArray
的用法示例。
在下文中一共展示了RawArray.filter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: preprocess_ts
# 需要导入模块: from mne.io import RawArray [as 别名]
# 或者: from mne.io.RawArray import filter [as 别名]
def preprocess_ts(ts_file,orig_channel_names_file,orig_channel_coords_file, h_freq, orig_sfreq, down_sfreq ,prefiltered = False):
from mne.io import RawArray
from mne import create_info
import os
import numpy as np
#### load electrode names
elec_names = [line.strip() for line in open(orig_channel_names_file)]
#print elec_names
### save electrode locations
elec_loc = np.loadtxt(orig_channel_coords_file)
#print elec_loc
### no modification on electrode names and locations
correct_elec_loc = elec_loc
correct_elec_names = elec_names
print len(correct_elec_names)
print len(correct_elec_loc)
### save electrode locations
channel_coords_file = os.path.abspath("correct_channel_coords.txt")
np.savetxt(channel_coords_file ,correct_elec_loc , fmt = '%s')
#### save electrode names
channel_names_file = os.path.abspath("correct_channel_names.txt")
np.savetxt(channel_names_file,correct_elec_names , fmt = '%s')
##### downsampling on data
if orig_sfreq != down_sfreq:
ts = np.load(ts_file)
print ts.shape
raw = RawArray(ts, info = create_info(ch_names = elec_names, sfreq = orig_sfreq))
indexes_good_elec = np.arange(len(elec_names))
print indexes_good_elec
if prefiltered == False:
raw.filter(l_freq = None, h_freq = down_sfreq, picks = indexes_good_elec)
raw.resample(sfreq = down_sfreq,npad = 100)
downsampled_ts,times = raw[:,:]
print downsampled_ts.shape
downsampled_ts_file = os.path.abspath("downsampled_ts.npy")
np.save(downsampled_ts_file,downsampled_ts)
print raw.info['sfreq']
return downsampled_ts_file,channel_coords_file,channel_names_file,raw.info['sfreq']
else:
print "No downsampling was applied as orig_sfreq and down_sfreq are identical"
return ts_file,channel_coords_file,channel_names_file,orig_sfreq