plot_meg_inverse_solution.py 1.5 KB
Newer Older
1
"""
2 3
Plot MEG inverse solution
=========================
4

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

7
"""
8 9
print __doc__

10
import os
11 12 13
import numpy as np

from surfer import Brain, TimeViewer
14
from surfer.io import read_stc
15 16

"""
17
define subject, surface and hemisphere(s) to plot
18
"""
19
subject_id, surface = 'fsaverage', 'inflated'
Eric Larson's avatar
Eric Larson committed
20
hemi = 'split'
21 22 23 24 25 26 27 28 29

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

"""
read MNE dSPM inverse solution
"""
30 31 32 33
for hemi in ['lh', 'rh']:
    stc_fname = os.path.join('example_data',
                             'meg_source_estimate-' + hemi + '.stc')
    stc = read_stc(stc_fname)
34

35 36 37 38 39
    """
    data and vertices for which the data is defined
    """
    data = stc['data']
    vertices = stc['vertices']
40

41 42 43 44 45 46 47 48 49 50
    """
    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'
51

52 53 54 55
    """
    label for time annotation
    """
    time_label = 'time=%0.2f ms'
56

57 58 59
    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=10, time=time, time_label=time_label,
                   hemi=hemi)
60 61

"""
62
scale colormap and set time (index) to display
63
"""
64 65
brain.set_data_time_index(2)
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
Martin Luessi's avatar
Martin Luessi committed
66 67

"""
68
uncomment this line to use the interactive TimeViewer GUI
Martin Luessi's avatar
Martin Luessi committed
69
"""
Martin Luessi's avatar
Martin Luessi committed
70
#viewer = TimeViewer(brain)