File: viz_volume_data.py

package info (click to toggle)
nipy 0.1.2%2B20100526-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 11,992 kB
  • ctags: 13,434
  • sloc: python: 47,720; ansic: 41,334; makefile: 197
file content (25 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (3)
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
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
Use Mayavi to visualize the structure of a VolumeData
"""

from enthought.mayavi import mlab
import numpy as np

x, y, z, s = np.random.random((4, 20))

mlab.figure(1, fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
mlab.clf()

src = mlab.pipeline.scalar_scatter(x, y, z, s)
sgrid = mlab.pipeline.delaunay3d(src)

mlab.pipeline.surface(sgrid, opacity=0.4)
mlab.pipeline.surface(mlab.pipeline.extract_edges(sgrid), color=(0, 0, 0))
mlab.pipeline.glyph(sgrid, mode='cube', scale_factor=0.05, scale_mode='none')
mlab.savefig('volume_data.jpg')
mlab.show()