Skip to content

Commit 5e401d2

Browse files
EXA: add Brain.save_movie() example
1 parent b7bb299 commit 5e401d2

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

examples/save_movie.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Create movie from MEG inverse solution
3+
=======================================
4+
5+
Data were computed using mne-python (http://martinos.org/mne)
6+
7+
"""
8+
print __doc__
9+
10+
import os
11+
import numpy as np
12+
13+
from surfer import Brain
14+
from surfer.io import read_stc
15+
16+
"""
17+
create Brain object for visualization
18+
"""
19+
brain = Brain('fsaverage', 'split', 'inflated',
20+
config_opts=dict(width=800, height=400))
21+
22+
"""
23+
read MNE dSPM inverse solution
24+
"""
25+
for hemi in ['lh', 'rh']:
26+
stc_fname = os.path.join('example_data',
27+
'meg_source_estimate-' + hemi + '.stc')
28+
stc = read_stc(stc_fname)
29+
data = stc['data']
30+
31+
"""
32+
time points in milliseconds
33+
"""
34+
time = 1e3 * np.linspace(stc['tmin'],
35+
stc['tmin'] + data.shape[1] * stc['tstep'],
36+
data.shape[1])
37+
38+
brain.add_data(data, colormap='hot', vertices=stc['vertices'],
39+
smoothing_steps=10, time=time, time_label='time=%0.2f ms',
40+
hemi=hemi)
41+
42+
"""
43+
scale colormap
44+
"""
45+
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
46+
47+
"""
48+
Save movies with different combinations of views
49+
"""
50+
brain.save_movie('example_current.mov')
51+
brain.save_movie('example_single.mov', montage='single')
52+
brain.save_movie('example_h.mov', montage=['lat', 'med'], orientation='h')
53+
brain.save_movie('example_v.mov', montage=[['lat'], ['med']])
54+
55+
brain.close()

0 commit comments

Comments
 (0)