In [1]:
import sys
sys.version_info
del sys # module sysの読み込み中止

自発波形 raw FIFFの表示

準備

In [2]:
import os.path as op
import numpy as np
import mne
mne.set_log_level('INFO')
data_path=op.join(mne.datasets.sample.data_path(),'MEG','sample') # このコードは
print(data_path)
data_path=mne.datasets.sample.data_path()+'\\MEG\\sample' # このコードと同じ意味です
print(data_path)
C:\Users\akira\mne_data\MNE-sample-data\MEG\sample
C:\Users\akira\mne_data\MNE-sample-data\MEG\sample

op.joinを使わなくてもpythonは+' 'で代用できます。

In [3]:
raw=mne.io.read_raw_fif(op.join(data_path,'sample_audvis_raw.fif'))
print(raw)
raw.set_eeg_reference() # EEG averageを関電位とする
events=mne.read_events(op.join(data_path,'sample_audvis_raw-eve.fif'))
events.shape
Opening raw data file C:\Users\akira\mne_data\MNE-sample-data\MEG\sample\sample_audvis_raw.fif...
    Read a total of 3 projection items:
        PCA-v1 (1 x 102)  idle
        PCA-v2 (1 x 102)  idle
        PCA-v3 (1 x 102)  idle
    Range : 25800 ... 192599 =     42.956 ...   320.670 secs
Ready.
Current compensation grade : 0
<Raw  |  sample_audvis_raw.fif, n_channels x n_times : 376 x 166800 (277.7 sec), ~3.7 MB, data not loaded>
Adding average EEG reference projection.
1 projection items deactivated
Out[3]:
(320L, 3L)
In [4]:
raw.plot(block=True); # jupyterでは;をつけないと2個絵が出てきます。
In [5]:
raw.plot(order='selection');
In [6]:
raw.plot_sensors(kind='3d',ch_type='mag',ch_groups='position');

SSPの追加です

In [7]:
projs=mne.read_proj(op.join(data_path,'sample_audvis_eog-proj.fif'));
print(projs);
raw.add_proj(projs)
raw.plot_projs_topomap();
    Read a total of 6 projection items:
        EOG-planar-998--0.200-0.200-PCA-01 (1 x 203)  idle
        EOG-planar-998--0.200-0.200-PCA-02 (1 x 203)  idle
        EOG-axial-998--0.200-0.200-PCA-01 (1 x 102)  idle
        EOG-axial-998--0.200-0.200-PCA-02 (1 x 102)  idle
        EOG-eeg-998--0.200-0.200-PCA-01 (1 x 59)  idle
        EOG-eeg-998--0.200-0.200-PCA-02 (1 x 59)  idle
[<Projection  |  EOG-planar-998--0.200-0.200-PCA-01, active : False, n_channels : 203>, <Projection  |  EOG-planar-998--0.200-0.200-PCA-02, active : False, n_channels : 203>, <Projection  |  EOG-axial-998--0.200-0.200-PCA-01, active : False, n_channels : 102>, <Projection  |  EOG-axial-998--0.200-0.200-PCA-02, active : False, n_channels : 102>, <Projection  |  EOG-eeg-998--0.200-0.200-PCA-01, active : False, n_channels : 59>, <Projection  |  EOG-eeg-998--0.200-0.200-PCA-02, active : False, n_channels : 59>]
6 projection items deactivated