import numpy as np import neo ? ? import mne import matplotlib.pyplot as plt # 创建任意数据 sfreq = 20 ?# 采样频率 times = np.arange(0, 5, 0.05) ?# Use 10000 samples (10s) ? ? sin = np.sin(times * 10) ?# 乘以 10 缩短周期 cos = np.cos(times * 10) sinX2 = sin * 2 cosX2 = cos * 2 ? ? # 数组大小为 4 X 10000. data = np.array([sin]) ? ? # 定义 channel types and names. ch_types = ['mag'] ch_names = ['sin']
""" 创建info对象 """ info = mne.create_info(ch_names=ch_names, ? ? ? ? ? ? ? ? ? ? ? ?sfreq=sfreq,? ? ? ? ? ? ? ? ? ? ? ? ?ch_types=ch_types) """ 利用mne.io.RawArray创建raw对象 """ #raw = mne.io.RawArray(data, info)
#picks = mne.pick_types( # ? ? ? info, meg=False, eeg=True, stim=False, # ? ? ? ?include=ch_names # ? ?) #raw.save("raw.fif", picks=picks, overwrite=True)
print(info) #print(raw) #print(data) """ 对图形进行缩放 对于实际的EEG / MEG数据,应使用不同的比例因子。 对通道mag的数据进行2倍缩小,对grad的数据进行1.7倍缩小 """ #scalings = {'mag': 2, 'grad':1.7} ? ? #raw.plot(n_channels=4, scalings=scalings, title='Data from arrays',show=True, block=True) ? ? """ 可以采用自动缩放比例 只要设置scalings='auto'即可 """
#scalings = 'auto' #raw.plot(n_channels=4, scalings=scalings,title='Auto-scaled Data from arrays',show=True, block=True) #plt.show()
(mne-1.0.0_0) D:\>python raw_test3.py <Info | 7 non-empty values ?bads: [] ?ch_names: sin ?chs: 1 Magnetometers ?custom_ref_applied: False ?highpass: 0.0 Hz ?lowpass: 10.0 Hz ?meas_date: unspecified ?nchan: 1 ?projs: [] ?sfreq: 20.0 Hz >
|