本文整理汇总了Python中surfer.Brain.save_movie方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.save_movie方法的具体用法?Python Brain.save_movie怎么用?Python Brain.save_movie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surfer.Brain
的用法示例。
在下文中一共展示了Brain.save_movie方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_movie
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import save_movie [as 别名]
def test_movie():
"""Test saving a movie of an MEG inverse solution
"""
# create and setup the Brain instance
mlab.options.backend = 'auto'
brain = Brain(*std_args)
stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
stc = io.read_stc(stc_fname)
data = stc['data']
time = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin']
brain.add_data(data, colormap='hot', vertices=stc['vertices'],
smoothing_steps=10, time=time, time_label='time=%0.2f ms')
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
# save movies with different options
tempdir = mkdtemp()
try:
dst = os.path.join(tempdir, 'test.mov')
brain.save_movie(dst)
brain.save_movie(dst, tmin=0.081, tmax=0.102)
# test the number of frames in the movie
sp = subprocess.Popen(('ffmpeg', '-i', 'test.mov', '-vcodec', 'copy',
'-f', 'null', '/dev/null'), cwd=tempdir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = sp.communicate()
m = re.search('frame=\s*(\d+)\s', stderr)
if not m:
raise RuntimeError(stderr)
n_frames = int(m.group(1))
assert_equal(n_frames, 3)
finally:
# clean up
shutil.rmtree(tempdir)
brain.close()
示例2: test_movie
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import save_movie [as 别名]
def test_movie():
"""Test saving a movie of an MEG inverse solution."""
import imageio
# create and setup the Brain instance
_set_backend()
brain = Brain(*std_args)
stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
stc = io.read_stc(stc_fname)
data = stc['data']
time = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin']
brain.add_data(data, colormap='hot', vertices=stc['vertices'],
smoothing_steps=10, time=time, time_label='time=%0.2f ms')
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
# save movies with different options
tempdir = mkdtemp()
try:
dst = os.path.join(tempdir, 'test.mov')
# test the number of frames in the movie
brain.save_movie(dst)
frames = imageio.mimread(dst)
assert_equal(len(frames), 2)
brain.save_movie(dst, time_dilation=10)
frames = imageio.mimread(dst)
assert_equal(len(frames), 7)
brain.save_movie(dst, tmin=0.081, tmax=0.102)
frames = imageio.mimread(dst)
assert_equal(len(frames), 2)
finally:
# clean up
if not (sys.platform == 'win32' and
os.getenv('APPVEYOR', 'False') == 'True'): # cleanup problems
shutil.rmtree(tempdir)
brain.close()
示例3: test_movie
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import save_movie [as 别名]
def test_movie(tmpdir):
"""Test saving a movie of an MEG inverse solution."""
import imageio
if sys.version_info < (3,):
raise SkipTest('imageio ffmpeg requires Python 3')
# create and setup the Brain instance
_set_backend()
brain = Brain(*std_args)
stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
stc = io.read_stc(stc_fname)
data = stc['data']
time = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin']
brain.add_data(data, colormap='hot', vertices=stc['vertices'],
smoothing_steps=10, time=time, time_label='time=%0.2f ms')
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
# save movies with different options
dst = str(tmpdir.join('test.mov'))
# test the number of frames in the movie
brain.save_movie(dst)
frames = imageio.mimread(dst)
assert len(frames) == 2
brain.save_movie(dst, time_dilation=10)
frames = imageio.mimread(dst)
assert len(frames) == 7
brain.save_movie(dst, tmin=0.081, tmax=0.102)
frames = imageio.mimread(dst)
assert len(frames) == 2
brain.close()
示例4: Brain
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import save_movie [as 别名]
"""
create Brain object for visualization
"""
brain = Brain('fsaverage', 'split', 'inflated', size=(800, 400))
"""
read and display MNE dSPM inverse solution
"""
stc_fname = os.path.join('example_data', 'meg_source_estimate-%s.stc')
for hemi in ['lh', 'rh']:
stc = read_stc(stc_fname % hemi)
data = stc['data']
times = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin']
brain.add_data(data, colormap='hot', vertices=stc['vertices'],
smoothing_steps=10, time=times, hemi=hemi,
time_label=lambda t: '%s ms' % int(round(t * 1e3)))
"""
scale colormap
"""
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
"""
Save a movie. Use a large value for time_dilation because the sample stc only
covers 30 ms.
"""
brain.save_movie('example_current.mov', time_dilation=30)
brain.close()