In [1]:
import sys
sys.version_info
Out[1]:
sys.version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)

波形・周波数・トポグラフィ表示

Python 2.7.13です。 いろいろimportして準備します。

In [2]:
import numpy as np
import mne
from mne.datasets import sample
from mne.preprocessing import create_ecg_epochs,create_eog_epochs
mne.set_log_level('INFO')

data_path=sample.data_path()
raw_fname=data_path+'\\MEG\\sample\\sample_audvis_raw.fif'

脳磁図自発波形表示

raw.fifを読み込みます。メモリ上にデータを残すのでpreload=Trueとします。

In [3]:
raw=mne.io.read_raw_fif(raw_fname,preload=True) # raw.fifの読み込み
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
Reading 0 ... 166799  =      0.000 ...   277.714 secs...

SSPはPCA-v1とPCA-v2とPCA-v3の3つがあります。1 x 102なので全部magnetometer用です。

In [4]:
meg=raw.copy().pick_types(meg='mag'); # magnetometerのみ
print(meg);
projs=meg.info["projs"];
print(projs)
meg=meg.del_proj([0,1]); # PCA-v1とPCA-v2が消える
projs=meg.info["projs"];
print(projs)
meg.plot(duration=60,n_channels=102,remove_dc=False);
<Raw  |  sample_audvis_raw.fif, n_channels x n_times : 102 x 166800 (277.7 sec), ~133.0 MB, data loaded>
[<Projection  |  PCA-v1, active : False, n_channels : 102>, <Projection  |  PCA-v2, active : False, n_channels : 102>, <Projection  |  PCA-v3, active : False, n_channels : 102>]
[<Projection  |  PCA-v3, active : False, n_channels : 102>]

カーソルバーはjupyterだと動きません

脳磁図自発波形周波数表示

In [5]:
raw.plot_psd(tmax=np.inf,fmax=250);
C:\Users\akira\Anaconda2\lib\site-packages\mne\viz\raw.py:614: DeprecationWarning: In version 0.15 average will default to False and spatial_colors will default to True.
  'spatial_colors will default to True.', DeprecationWarning)
Effective window size : 3.410 (s)
Effective window size : 3.410 (s)
Effective window size : 3.410 (s)

加算脳波波形とトポグラフィ表示

In [6]:
average_eog=create_eog_epochs(raw).average()
print(average_eog);
print('We found %i EOG events' % average_eog.nave)
average_eog.plot_joint();
EOG channel index for this subject is: [375]
Filtering the data to remove DC offset to help distinguish blinks from saccades
Setting up band-pass filter from 2 - 45 Hz
Setting up band-pass filter from 1 - 10 Hz
Now detecting blinks and generating corresponding events
Number of EOG events detected : 46
46 matching events found
Created an SSP operator (subspace dimension = 3)
Loading data for 46 events and 601 original time points ...
0 bad epochs dropped
<Evoked  |  comment : '998', kind : average, time : [-0.499488, 0.499488], n_epochs : 46, n_channels x n_times : 366 x 601, ~5.4 MB>
We found 46 EOG events