File: plot_meg_inverse_solution.py

package info (click to toggle)
pysurfer 0.3%2Bgit15-gae6cbb1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,032 kB
  • sloc: python: 1,947; makefile: 125
file content (67 lines) | stat: -rw-r--r-- 1,375 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
Plot MEG inverse solution
=========================

Data were computed using mne-python (http://martinos.org/mne)

"""
print __doc__

import os
import numpy as np

from surfer import Brain, TimeViewer
from surfer.io import read_stc

"""
define subject, surface and hemisphere
"""
subject_id, surface, hemi = 'fsaverage', 'inflated', 'lh'

"""
create Brain object for visualization
"""
brain = Brain(subject_id, hemi, surface)

"""
read MNE dSPM inverse solution
"""
stc_fname = os.path.join('example_data',
                         'meg_source_estimate-' + hemi + '.stc')
stc = read_stc(stc_fname)

"""
data and vertices for which the data is defined
"""
data = stc['data']
vertices = stc['vertices']

"""
time points in milliseconds
"""
time = 1e3 * np.linspace(stc['tmin'],
                         stc['tmin'] + data.shape[1] * stc['tstep'],
                         data.shape[1])
"""
colormap to use
"""
colormap = 'hot'

"""
label for time annotation
"""
time_label = 'time=%0.2f ms'

brain.add_data(data, colormap=colormap, vertices=vertices, smoothing_steps=10,
               time=time, time_label=time_label)

"""
scale colormap and set time (index) to display
"""
brain.set_data_time_index(2)
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)

"""
uncomment this line to use the interactive TimeViewer GUI
"""
#viewer = TimeViewer(brain)